Changeset bba1c4 in git


Ignore:
Timestamp:
Oct 14, 1998, 12:18:25 PM (26 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c7af8613769b29c741d6c338945669719f1fc4f8')
Children:
80419f2e14f3f3e1cf9e13aed52d5098cb0acdda
Parents:
649af033c39d83179353755b84eaed2c7be55a01
Message:
1998-10-14  Olaf Bachmann  <obachman@mathematik.uni-kl.de>

	    * MP_TcpTransp.c: added MP_KillLink, -MPrsh option to
              MP_OpenLink

	      * MP_Util.c: Added IMP_StrDup function


git-svn-id: file:///usr/local/Singular/svn/trunk@2562 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
MP/MP
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • MP/MP/ChangeLog

    r649af0 rbba1c4  
     11998-10-14  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
     2
     3        * MP_TcpTransp.c: added MP_KillLink, -MPrsh option to MP_OpenLink
     4
     5        * MP_Util.c: Added IMP_StrDup function
     6
    171998-04-16  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
    28
  • MP/MP/MP.h

    r649af0 rbba1c4  
    697697    MP_Status_t  (*open_transp)VARARGS;     /* open the transport device   */
    698698    MP_Status_t  (*close_transp)VARARGS;    /* close the transport device  */
     699    MP_Status_t  (*kill_transp)VARARGS;    /* kill the transport device  */
    699700} MP_TranspOps_t;
    700701
     
    862863EXTERN void MP_CloseLink _ANSI_ARGS_((MP_Link_pt link));
    863864
     865EXTERN void MP_KillLink _ANSI_ARGS_((MP_Link_pt link));
     866
    864867EXTERN MP_Status_t MP_PeekHeader _ANSI_ARGS_((MP_Link_pt link,
    865868                                              MP_NodeType_t *ntype,
     
    968971#define log_msg_len 128
    969972
     973EXTERN char *IMP_StrDup  _ANSI_ARGS_((char* s));
     974
    970975EXTERN void MP_LogEvent _ANSI_ARGS_((MP_Link_pt link, char *event, char *msg));
    971976
     
    973978                                            MP_Status_t the_err));
    974979
    975 #define MP_ClearError(link) (link)->errno = MP_Success
     980#define MP_ClearError(link) ((MP_Status_t) (link)->errno = MP_Success)
    976981
    977982EXTERN void MP_PrintError _ANSI_ARGS_((MP_Link_pt link));
     
    14441449MP_Status_t tcp_open_connection _ANSI_ARGS_((MP_Link_pt, int, char**));
    14451450MP_Status_t tcp_close_connection _ANSI_ARGS_((MP_Link_pt));
     1451MP_Status_t tcp_kill_connection _ANSI_ARGS_((MP_Link_pt));
    14461452MP_Status_t open_tcp_connect_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
    14471453MP_Status_t open_tcp_listen_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
     
    14591465    char    *myhost;
    14601466    MP_LinkStatus_t status;
     1467    pid_t   peerpid;
     1468  char *rsh;
     1469  int mode;
    14611470} MP_TCP_t;
    14621471
  • MP/MP/MP_FileTransp.c

    r649af0 rbba1c4  
    4646
    4747#ifndef lint
    48 static char vcid[] = "@(#) $Id: MP_FileTransp.c,v 1.1.1.1 1997-05-25 20:31:46 obachman Exp $";
     48static char vcid[] = "@(#) $Id: MP_FileTransp.c,v 1.2 1998-10-14 10:18:10 obachman Exp $";
    4949#endif /* lint */
    5050
     
    9090    file_get_status,
    9191    file_open_connection,
     92    file_close_connection,
    9293    file_close_connection
    9394};
  • MP/MP/MP_Link.c

    r649af0 rbba1c4  
    139139
    140140#ifndef lint
    141 static char vcid[] = "@(#) $Id: MP_Link.c,v 1.2 1997-06-28 13:30:26 obachman Exp $";
     141static char vcid[] = "@(#) $Id: MP_Link.c,v 1.3 1998-10-14 10:18:11 obachman Exp $";
    142142#endif /* lint */
    143143
     
    290290
    291291    if ((tp_ops = IMP_GetTranspByName(env, transp_dev)) == NULL) {
    292         msg = IMP_RawMemAllocFnc(strlen(transp) + 28);
     292        msg = (char*) IMP_RawMemAllocFnc(strlen(transp) + 28);
    293293        sprintf(msg, "Unknown transport device %s", transp);
    294294        MP_LogEvent(link, MP_ERROR_EVENT, msg);
     
    298298
    299299    if (tp_ops->transp_ops.open_transp(link, argc, argv) != MP_Success) {
    300         msg = IMP_RawMemAllocFnc(strlen(transp) + 46);
     300        msg = (char*) IMP_RawMemAllocFnc(strlen(transp) + 46);
    301301        sprintf(msg, "MP_OpenLink: Couldn't open %s transport device",
    302302                transp);
     
    308308#ifndef NO_LOGGING
    309309    fprintf(env->logfd, "L%d: Application: %s\n", link->link_id, argv[0]);
    310     msg = IMP_RawMemAllocFnc(strlen(transp) + 46);
     310    msg = (char*) IMP_RawMemAllocFnc(strlen(transp) + 46);
    311311    sprintf(msg, "MP_OpenLink: opened link for transport %s",
    312312            transp);
     
    386386    return;
    387387}
     388
     389#ifdef __STDC__
     390void MP_KillLink(MP_Link_pt link)
     391#else
     392void MP_KillLink(link)
     393    MP_Link_pt link;
     394#endif
     395{
     396    buffer_handle_pt cur_buff, old_buff;
     397
     398#ifdef MP_DEBUG
     399    fprintf(stderr, "MP_KillLink: entering for link %d\n", link->link_id);
     400#endif
     401
     402    if (link != NULL) {
     403        if ((cur_buff = link->o_buff) == NULL)
     404            return;
     405
     406      /* Check just in case the environment was released first. */
     407      /* It shouldn't have been, but you never know.            */
     408      if (link->env == NULL) {
     409        fprintf(stderr, "MP_KillLink: NULL environment pointer!!\n");
     410        return;
     411      }
     412
     413
     414        while (cur_buff != NULL) {
     415            old_buff = cur_buff;
     416            cur_buff = old_buff->next;
     417            free_buffer(link->env->buff_pool, old_buff);
     418        }
     419
     420        if ((cur_buff = link->i_buff) == NULL)
     421            return;
     422
     423        while (cur_buff != NULL) {
     424            old_buff = cur_buff;
     425            cur_buff = old_buff->next;
     426            free_buffer(link->env->buff_pool, old_buff);
     427        }
     428        link->transp.transp_ops->kill_transp(link);
     429
     430#ifndef NO_LOGGING
     431        if (link->logmask & MP_LOG_INIT_EVENTS)
     432            MP_LogEvent(link, MP_INIT_EVENT, "MP_KillLink: closed link\n");
     433#endif
     434
     435        IMP_MemFreeFnc(link, sizeof(MP_Link_t));
     436    }
     437
     438#ifdef MP_DEBUG
     439    fprintf(stderr, "MP_KillLink: exiting\n");
     440#endif
     441
     442    return;
     443}
     444
    388445
    389446
  • MP/MP/MP_PariBigInt.c

    r649af0 rbba1c4  
    114114char * IMP_PariBigIntToStr(MP_ApInt_t mp_number, char *buffer)
    115115{
    116   return gitoascii((GEN) mp_number, buffer);
     116//  return gitoascii((GEN) mp_number, buffer);
     117  return "Can not print";
    117118}
    118119
  • MP/MP/MP_PvmTransp.c

    r649af0 rbba1c4  
    5454
    5555#ifndef lint
    56 static char vcid[] = "@(#) $Id: MP_PvmTransp.c,v 1.1.1.1 1997-05-25 20:31:47 obachman Exp $";
     56static char vcid[] = "@(#) $Id: MP_PvmTransp.c,v 1.2 1998-10-14 10:18:15 obachman Exp $";
    5757#endif /* lint */
    5858
     
    8686  mp_pvm_get_status,
    8787  mp_pvm_open_connection,
     88  mp_pvm_close_connection,
    8889  mp_pvm_close_connection
    8990};
  • MP/MP/MP_TbTransp.c

    r649af0 rbba1c4  
    4545 ***************************************************************************/
    4646#ifndef lint
    47 static char vcid[] = "@(#) $Id: MP_TbTransp.c,v 1.1.1.1 1997-05-25 20:31:47 obachman Exp $";
     47static char vcid[] = "@(#) $Id: MP_TbTransp.c,v 1.2 1998-10-14 10:18:16 obachman Exp $";
    4848#endif /* lint */
    4949
     
    7676  mp_tb_get_status,
    7777  mp_tb_open_connection,
     78  mp_tb_close_connection,
    7879  mp_tb_close_connection
    7980};
  • MP/MP/MP_TcpTransp.c

    r649af0 rbba1c4  
    8181#include <string.h>
    8282#include <stdlib.h>
     83#include <signal.h>
    8384
    8485#ifdef __WIN32__
     
    104105static MP_Status_t tcp_negotiate_fp_format _ANSI_ARGS_((MP_Link_pt));
    105106static MP_Status_t tcp_negotiate_bigint_format _ANSI_ARGS_((MP_Link_pt));
     107static MP_Status_t tcp_exchange_pids _ANSI_ARGS_((MP_Link_pt));
    106108static int get_tcp_mode _ANSI_ARGS_((int, char**));
    107109
     
    117119    tcp_get_status,
    118120    tcp_open_connection,
    119     tcp_close_connection
     121    tcp_close_connection,
     122    tcp_kill_connection
    120123};
    121124
     
    213216      replace_by_that != NULL)
    214217  {
    215     ret = IMP_RawMemAllocFnc((strlen(str) 
     218    ret = (char*) IMP_RawMemAllocFnc((strlen(str) 
    216219                              + strlen(replace_by_that) - strlen(replace_this)
    217220                              + 1)*sizeof(char));
     
    457460    if (rsh_argv[0] == NULL)
    458461      rsh_argv[0] = MP_RSH_COMMAND;
     462    tcp_rec->rsh = IMP_StrDup(rsh_argv[0]);
     463
    459464    rsh_argv[1] = IMP_GetCmdlineArg(argc, argv, "-MPhost");
    460465    rsh_argv[2] = "-n";
     
    536541    rsh_argv[3] = appstr;
    537542    rsh_argv[4] = NULL;
     543    if (tcp_rec->peerhost == NULL)
     544      tcp_rec->peerhost = IMP_StrDup(rsh_argv[1]);
    538545
    539546    if ((rsh_pid = vfork()) == -1) {
     
    13151322    tcp_rec->peerhost = NULL;
    13161323    tcp_rec->status   = MP_UnknownStatus;
     1324    tcp_rec->rsh      = NULL;
    13171325
    13181326    link->transp.private1 = (char *)tcp_rec;
     
    13611369    if (tcp_rec->peerhost != NULL)
    13621370        IMP_RawMemFreeFnc(tcp_rec->peerhost);
     1371    if (tcp_rec->rsh != NULL)
     1372        IMP_RawMemFreeFnc(tcp_rec->rsh);
    13631373    IMP_MemFreeFnc(tcp_rec, sizeof(MP_TCP_t));
    13641374    link->transp.private1 = NULL;
     
    13721382}
    13731383
    1374 
    1375 
     1384#ifdef __STDC__
     1385MP_Status_t tcp_kill_connection(MP_Link_pt link)
     1386#else
     1387MP_Status_t tcp_kill_connection(link)
     1388    MP_Link_pt link;
     1389#endif
     1390{
     1391    MP_TCP_t *tcp_rec;
     1392    char *rsh_argv[4];
     1393    char rsh_kill[20];
     1394    int fork_pid = -1;
     1395   
     1396#ifdef MP_DEBUG
     1397    fprintf(stderr, "tcp_kill_connection: entering\n");
     1398    fflush(stderr);
     1399#endif /* MP_DEBUG */
     1400
     1401    TEST_LINK_NULL(link);
     1402    if (link->transp.private1 == NULL)
     1403        return MP_SetError(link, MP_NullTransport);
     1404    tcp_rec = (MP_TCP_t*)link->transp.private1;
     1405   
     1406    if (tcp_rec->mode == MP_LAUNCH_MODE)
     1407    {
     1408      rsh_argv[0] = tcp_rec->rsh;
     1409      rsh_argv[1] = tcp_rec->peerhost;
     1410      rsh_argv[2] = "-n";
     1411      sprintf(rsh_kill, "kill -9 %d", tcp_rec->peerpid);
     1412      rsh_argv[3] = rsh_kill;
     1413      rsh_argv[4] = NULL;
     1414
     1415      if ((fork_pid = vfork()) == -1)
     1416      {
     1417        MP_LogEvent(link, MP_ERROR_EVENT,
     1418                    "MP_OpenLink: can't fork to kill application");
     1419        return MP_SetError(link, MP_Failure);
     1420      }
     1421
     1422      if (! fork_pid)
     1423      {
     1424        execvp(rsh_argv[0], rsh_argv);
     1425        fputs("tcp_kill_connectione: execvp failed - bailing out\n", stderr);
     1426        fflush(stderr);
     1427        _exit(1);
     1428      }
     1429    }
     1430    else if (tcp_rec->mode == MP_FORK_MODE)
     1431    {
     1432      kill(tcp_rec->peerpid, SIGKILL);
     1433    }
     1434   
     1435    return tcp_close_connection(link);
     1436}
    13761437
    13771438/***********************************************************************
     
    14121473        return MP_Failure;
    14131474
    1414     switch (get_tcp_mode(argc, argv)) {
     1475    ((MP_TCP_t *)link->transp.private1)->mode = get_tcp_mode(argc, argv);
     1476    switch (((MP_TCP_t *)link->transp.private1)->mode)
     1477    {
    14151478    case MP_LISTEN_MODE:
    14161479        status = open_tcp_listen_mode(link, argc, argv);
     
    14601523    ERR_CHK(tcp_negotiate_fp_format(link));
    14611524    ERR_CHK(tcp_negotiate_bigint_format(link));
     1525    ERR_CHK(tcp_exchange_pids(link));
    14621526
    14631527#ifdef MP_DEBUG
     
    14701534
    14711535
    1472 
     1536#ifdef __STDC__
     1537static MP_Status_t tcp_exchange_pids(MP_Link_pt link)
     1538#else
     1539static MP_Status_t tcp_exchange_pids(link)
     1540    MP_Link_pt link;
     1541#endif
     1542{
     1543  MP_Uint32_t peerpid;
     1544  MP_NumAnnot_t na;
     1545
     1546  /* Hmm... should communicate pid_t -- could be 64 bit !! */
     1547  ERR_CHK(MP_PutUint32Packet(link, (MP_Uint32_t) getpid(), 0));
     1548  MP_EndMsgReset(link);
     1549 
     1550  ERR_CHK(MP_SkipMsg(link));
     1551  ERR_CHK(MP_GetUint32Packet(link, &peerpid, &na));
     1552  ((MP_TCP_t *)link->transp.private1)->peerpid = peerpid;
     1553
     1554  return MP_Success;
     1555}
    14731556
    14741557/*
  • MP/MP/MP_Util.c

    r649af0 rbba1c4  
    3838
    3939#ifndef lint
    40 static char vcid[] = "@(#) $Id: MP_Util.c,v 1.2 1998-04-16 16:17:06 obachman Exp $";
     40static char vcid[] = "@(#) $Id: MP_Util.c,v 1.3 1998-10-14 10:18:20 obachman Exp $";
    4141#endif /* lint */
    4242
     
    5252char fix_log_msg[log_msg_len];
    5353char AnnotFlagsStr[32];
     54
     55#ifdef __STDC__
     56char* IMP_StrDup(char* s)
     57#else
     58void IMP_StrDup(s)
     59  char* s;
     60#endif
     61{
     62  char* d = NULL;
     63 
     64  if (s != NULL)
     65  {
     66    d = (char*) IMP_RawMemAllocFnc(strlen(s) + 1);
     67    strcpy(d, s);
     68  }
     69  return d;
     70}
    5471
    5572#ifdef __STDC__
  • MP/MP/h/MP_Env.h

    r649af0 rbba1c4  
    5353    MP_Status_t  (*open_transp)VARARGS;     /* open the transport device   */
    5454    MP_Status_t  (*close_transp)VARARGS;    /* close the transport device  */
     55    MP_Status_t  (*kill_transp)VARARGS;    /* kill the transport device  */
    5556} MP_TranspOps_t;
    5657
  • MP/MP/h/MP_Link.h

    r649af0 rbba1c4  
    9595EXTERN void MP_CloseLink _ANSI_ARGS_((MP_Link_pt link));
    9696
     97EXTERN void MP_KillLink _ANSI_ARGS_((MP_Link_pt link));
     98
    9799EXTERN MP_Status_t MP_PeekHeader _ANSI_ARGS_((MP_Link_pt link,
    98100                                              MP_NodeType_t *ntype,
  • MP/MP/h/MP_TcpTransp.h

    r649af0 rbba1c4  
    8181MP_Status_t tcp_open_connection _ANSI_ARGS_((MP_Link_pt, int, char**));
    8282MP_Status_t tcp_close_connection _ANSI_ARGS_((MP_Link_pt));
     83MP_Status_t tcp_kill_connection _ANSI_ARGS_((MP_Link_pt));
    8384MP_Status_t open_tcp_connect_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
    8485MP_Status_t open_tcp_listen_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
     
    9697    char    *myhost;
    9798    MP_LinkStatus_t status;
     99    pid_t   peerpid;
     100  char *rsh;
     101  int mode;
    98102} MP_TCP_t;
    99103
  • MP/MP/h/MP_Util.h

    r649af0 rbba1c4  
    3737#define log_msg_len 128
    3838
     39EXTERN char *IMP_StrDup  _ANSI_ARGS_((char* s));
     40
    3941EXTERN void MP_LogEvent _ANSI_ARGS_((MP_Link_pt link, char *event, char *msg));
    4042
     
    4244                                            MP_Status_t the_err));
    4345
    44 #define MP_ClearError(link) (link)->errno = MP_Success
     46#define MP_ClearError(link) ((MP_Status_t) (link)->errno = MP_Success)
    4547
    4648EXTERN void MP_PrintError _ANSI_ARGS_((MP_Link_pt link));
Note: See TracChangeset for help on using the changeset viewer.