Changeset 61941e2 in git for MP/MP


Ignore:
Timestamp:
Jun 5, 1997, 6:39:13 PM (27 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
4e595a7b47d6ba4b8e2ca07d3de099932b5b9e33
Parents:
4f9ae6a6eb8da1c85be97e6a95dc85bee4e5edb1
Message:
* added fork mode to MP TCP links


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

Legend:

Unmodified
Added
Removed
  • MP/MP/ChangeLog

    r4f9ae6 r61941e2  
     1Tue May 27 13:57:13 1997  Olaf Bachmann  <obachman@ratchwu>
     2
     3        * MP_TcpTransp.h: Added fork mode to MPtcp links
     4
    15Tue May 20 17:38:53 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
    26
  • MP/MP/MP.h

    r4f9ae6 r61941e2  
    11
    2 /* MP.h automatically generated by ./makeheader.pl on Sun May 25 22:43:33 METDST 1997
     2/* MP.h automatically generated by ./makeheader.pl on Thu Jun  5 11:35:57 METDST 1997
    33*/
    44/****************************************************************
     
    100100
    101101/* For checking the status of a link*/
    102 enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting};
     102enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting,
     103                         MP_LinkIsParent};
    103104typedef enum link_status_option MP_LinkStatus_t;
    104105
     
    761762EXTERN MP_Status_t MP_SetEnvBigRealFormat _ANSI_ARGS_((MP_Env_t *env,
    762763                             MP_BigRealOps_t *ops, MP_BigNumFormat_t format));
    763  
     764EXTERN MP_Status_t open_logfile _ANSI_ARGS_((MP_ENV env));
    764765#endif /* _MP_Env_h */
    765766
     
    14251426#define MP_LISTEN_MODE          2
    14261427#define MP_LAUNCH_MODE          3
     1428#define MP_FORK_MODE            4
    14271429
    14281430/* Initial port for listening */
     
    14561458    char    *peerhost;
    14571459    char    *myhost;
     1460    char     isparent;
    14581461} MP_TCP_t;
    14591462
  • MP/MP/MP_Env.c

    r4f9ae6 r61941e2  
    5757
    5858#ifndef lint
    59 static char vcid[] = "@(#) $Id: MP_Env.c,v 1.1.1.1 1997-05-25 20:31:46 obachman Exp $";
     59static char vcid[] = "@(#) $Id: MP_Env.c,v 1.2 1997-06-05 16:38:52 obachman Exp $";
    6060#endif /*lint */
    6161
     
    183183
    184184      /* Store the log file name. */
    185       env->logfilename = IMP_MemAllocFnc(strlen(fname) + 1);
     185      env->logfilename = IMP_RawMemAllocFnc(strlen(fname) + 1);
    186186      if (env->logfilename == NULL) {
    187187        fprintf(stderr, "MP_InitializeEnv: can't allocate memory!!\n");
     
    346346    fprintf(env->logfd, "\nReleasing MP environment resources. \n");
    347347    fclose(env->logfd);
    348     IMP_MemFreeFnc(env->logfilename, strlen(env->logfilename));
     348    IMP_RawMemFreeFnc(env->logfilename);
    349349#endif
    350350
     
    495495
    496496#ifdef MP_DEBUG
    497     fprintf(stderr,"MP_AddEnvTranspDevice: entering to add device %s\n", name);
     497    fprintf(stderr,"MP_AddEnvTranspDevice: entering to add device %d\n", transp_dev);
    498498    fflush(stderr);
    499499#endif
  • MP/MP/MP_Get.c

    r4f9ae6 r61941e2  
    6666
    6767#ifndef lint
    68 static char vcid[] = "@(#) $Id: MP_Get.c,v 1.1.1.1 1997-05-25 20:31:46 obachman Exp $";
     68static char vcid[] = "@(#) $Id: MP_Get.c,v 1.2 1997-06-05 16:38:54 obachman Exp $";
    6969#endif /* lint */
    7070 
     
    177177#endif
    178178{
     179    unsigned char t;
     180    MP_Status_t status;
    179181#ifdef MP_DEBUG
    180182    fprintf(stderr, "IMP_GetNodeHeader: entering for link %d\n", link->link_id);
    181183#endif
    182     unsigned char t;
    183     MP_Status_t status;
    184184    /*
    185185     * For now we don't let the programmer in on this little secret (unless,
  • MP/MP/MP_GmpBigInt.c

    r4f9ae6 r61941e2  
    4848#endif
    4949{
     50  mpz_ptr apint = (mpz_ptr) mp_apint;
    5051#ifdef MP_DEBUG
    5152  fprintf(stderr, "IMP_PutGmpInt: entering\n"); fflush(stderr);
    5253#endif
    53   mpz_ptr apint = (mpz_ptr) mp_apint;
    5454
    5555  if (!IMP_PutLong(link, (long *)&(apint->_mp_size)))
  • MP/MP/MP_TcpTransp.c

    r4f9ae6 r61941e2  
    7474
    7575#ifndef lint
    76 static char vcid[] = "@(#) $Id: MP_TcpTransp.c,v 1.1.1.1 1997-05-25 20:31:47 obachman Exp $";
     76static char vcid[] = "@(#) $Id: MP_TcpTransp.c,v 1.2 1997-06-05 16:38:56 obachman Exp $";
    7777#endif /* lint */
    7878
     
    179179        else if (!strcmp(cmode, "launch"))
    180180            return MP_LAUNCH_MODE;
     181        else if (!strcmp(cmode, "fork"))
     182          return MP_FORK_MODE;
     183   
    181184
    182185#ifdef MP_DEBUG
     
    613616
    614617/***********************************************************************
     618 * FUNCTION:  open_tcp_fork_mode
     619 * INPUT:     link - pointer to link structure for this connection
     620 * OUTPUT:    Success:  MP_Success
     621 *                      socket connected to the a forked child
     622 *            Failure:  MP_Failure - couldn't make the connection.
     623 * OPERATION: forks a child, establishes a connection to it and uses
     624 *            the return of the fork to set parent/child attribute
     625 ***********************************************************************/
     626#ifdef __STDC__
     627MP_Status_t open_tcp_fork_mode(MP_Link_pt link, int argc, char** argv)
     628#else
     629MP_Status_t open_tcp_fork_mode(link, argc, argv)
     630    MP_Link_pt   link;
     631    int          argc;
     632    char**       argv;
     633#endif
     634{
     635  int pid;
     636  MP_TCP_t *tcp_rec = (MP_TCP_t *) link->transp.private1;
     637#ifndef NO_LOGGING
     638  char log_msg[200];
     639  char *parent_logfilename = link->env->logfilename;
     640  FILE *parent_logfd = link->env->logfd;
     641#endif
     642 
     643  /* prepare the socket */
     644  if (open_tcp_listen_mode(link, argc, argv) != MP_Success)
     645  {
     646    MP_LogEvent(link, MP_ERROR_EVENT,
     647                "MP_OpenLink: can't open a listening socket");
     648    return MP_SetError(link, MP_CantConnect);
     649  }
     650
     651#ifndef NO_LOGGING
     652  /* Open the log file before the fork, so that the processes do not
     653     get out of sync */
     654  sprintf(log_msg,
     655          "open_tcp_fork: Preparing to create fork link, parent id: %d",
     656          getpid());
     657  if (open_logfile(link->env) != MP_Success) return MP_Failure;
     658  MP_LogEvent(link, MP_INIT_EVENT,
     659              "open_tcp_fork: MP Log file for a forked (child) link");
     660  sprintf(log_msg, "open_tcp_fork: Parent link: L%d, logfile: %s, pid: %d",
     661          link->link_id, parent_logfilename, getpid());
     662  MP_LogEvent(link, MP_INIT_EVENT, log_msg);
     663#endif
     664 
     665  /* Do the fork */
     666  if ((pid = fork()) == -1)
     667  {
     668#ifndef NO_LOGGING
     669    link->env->logfilename = parent_logfilename;
     670    link->env->logfd = parent_logfd;
     671#endif   
     672    MP_LogEvent(link, MP_ERROR_EVENT, "MP_OpenLink: can't fork");
     673    return MP_SetError(link, MP_Failure);
     674  }
     675
     676  if (!pid)
     677  {
     678    /* Child's business */
     679    MP_Status_t stat;
     680    char cport[12];
     681    char *argv[] = {"MPtransp","TCP","-MPmode","connect","-MPhost",
     682                    "localhost", "-MPport", ""};
     683    sprintf(cport,"%d",tcp_rec->peerport);
     684    argv[7] = cport;
     685    tcp_rec->isparent = 0;
     686
     687    /* establish connection */
     688    stat = open_tcp_connect_mode(link, 8, argv);
     689
     690#ifndef NO_LOGGING
     691    IMP_RawMemFreeFnc(parent_logfilename);
     692    if (stat == MP_Success)
     693      sprintf(log_msg, "open_tcp_fork: opened forked link, child id: %d",
     694              getpid());
     695    else
     696      sprintf(log_msg,
     697              "open_tcp_fork: open of forked link failed, child is exited");
     698    MP_LogEvent(link, MP_ERROR_EVENT, log_msg);
     699#endif
     700    if (stat != MP_Success)
     701      _exit(1);
     702    else
     703      return MP_Success;
     704  }
     705  else
     706  {
     707    /* parent's business */
     708#ifndef NO_LOGGING
     709    /* reset logging stuff */
     710    link->env->logfilename = parent_logfilename;
     711    link->env->logfd = parent_logfd;
     712#endif
     713
     714    /* establish connection */
     715    socket_accept_blocking(link, &tcp_rec->sock);
     716    tcp_rec->isparent = 1;
     717
     718#ifndef NO_LOGGING
     719    sprintf(log_msg,"open_tcp_fork: opened fork link, parent id: %d",
     720            getpid());
     721    MP_LogEvent(link, MP_INIT_EVENT, log_msg);
     722#endif
     723
     724    RETURN_OK(link);
     725  }
     726}
     727 
     728/***********************************************************************
    615729 * FUNCTION:  open_tcp_connect_mode
    616730 * INPUT:     link - pointer to link structure for this connection
     
    878992    printf("tcp_get_status: entering for link %d\n", link->link_id);
    879993#endif
     994  if (status_to_check == MP_LinkIsParent)
     995  {
     996    if (((MP_TCP_t *)link->transp.private1)->isparent)
     997      return MP_TRUE;
     998    else
     999      return MP_FALSE;
     1000  }
    8801001
    8811002    FD_ZERO(&mask);
     
    11221243    tcp_rec->myhost   = NULL;
    11231244    tcp_rec->peerhost = NULL;
     1245    tcp_rec->isparent   = 0;
    11241246
    11251247    link->transp.private1 = (char *)tcp_rec;
     
    11321254    RETURN_OK(link);
    11331255}
    1134 
    1135 
    11361256
    11371257/***********************************************************************
     
    12381358        break;
    12391359
     1360        case MP_FORK_MODE:
     1361          status = open_tcp_fork_mode(link, argc, argv);
     1362          break;
     1363         
    12401364    default:
    12411365        MP_LogEvent(link, MP_ERROR_EVENT,
  • MP/MP/Makefile.in

    r4f9ae6 r61941e2  
    119119        rm -f MP.h
    120120       
    121 MP.h: ${HEADERS} 
     121MP.h: ${HEADERS}
    122122        perl ./makeheader.pl -I${hdir} ${hdir}/MP.h MP.h
    123123
  • MP/MP/h/ChangeLog

    r4f9ae6 r61941e2  
     1Thu Jun  5 12:02:12 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
     2
     3        * MP_Config.h.in: added WORDS_BIGENDIAN target
     4
    15Sun May 25 11:11:47 1997  Simon Gray  (sgray@Pooh)
    26
  • MP/MP/h/MP_Config.h.in

    r4f9ae6 r61941e2  
    5252#undef HAVE_SYS_SELECT_H
    5353
     54/* Define if you have BIG ENDIAN numbers */
     55#ifndef WORDS_BIGENDIAN
     56#undef WORDS_BIGENDIAN
     57#endif
     58
    5459/* Define to turn off logging */
    5560#undef NO_LOGGING
  • MP/MP/h/MP_Env.h

    r4f9ae6 r61941e2  
    118118EXTERN MP_Status_t MP_SetEnvBigRealFormat _ANSI_ARGS_((MP_Env_t *env,
    119119                             MP_BigRealOps_t *ops, MP_BigNumFormat_t format));
    120  
     120EXTERN MP_Status_t open_logfile _ANSI_ARGS_((MP_ENV env));
    121121#endif /* _MP_Env_h */
  • MP/MP/h/MP_TcpTransp.h

    r4f9ae6 r61941e2  
    6363#define MP_LISTEN_MODE          2
    6464#define MP_LAUNCH_MODE          3
     65#define MP_FORK_MODE            4
    6566
    6667/* Initial port for listening */
     
    9495    char    *peerhost;
    9596    char    *myhost;
     97    char     isparent;
    9698} MP_TCP_t;
    9799
  • MP/MP/h/MP_Types.h

    r4f9ae6 r61941e2  
    3636
    3737/* For checking the status of a link*/
    38 enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting};
     38enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting,
     39                         MP_LinkIsParent};
    3940typedef enum link_status_option MP_LinkStatus_t;
    4041
Note: See TracChangeset for help on using the changeset viewer.