Changeset 61941e2 in git
- Timestamp:
- Jun 5, 1997, 6:39:13 PM (26 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 4e595a7b47d6ba4b8e2ca07d3de099932b5b9e33
- Parents:
- 4f9ae6a6eb8da1c85be97e6a95dc85bee4e5edb1
- Location:
- MP/MP
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
MP/MP/ChangeLog
r4f9ae6 r61941e2 1 Tue May 27 13:57:13 1997 Olaf Bachmann <obachman@ratchwu> 2 3 * MP_TcpTransp.h: Added fork mode to MPtcp links 4 1 5 Tue May 20 17:38:53 1997 Olaf Bachmann <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)> 2 6 -
MP/MP/MP.h
r4f9ae6 r61941e2 1 1 2 /* MP.h automatically generated by ./makeheader.pl on Sun May 25 22:43:33METDST 19972 /* MP.h automatically generated by ./makeheader.pl on Thu Jun 5 11:35:57 METDST 1997 3 3 */ 4 4 /**************************************************************** … … 100 100 101 101 /* For checking the status of a link*/ 102 enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting}; 102 enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting, 103 MP_LinkIsParent}; 103 104 typedef enum link_status_option MP_LinkStatus_t; 104 105 … … 761 762 EXTERN MP_Status_t MP_SetEnvBigRealFormat _ANSI_ARGS_((MP_Env_t *env, 762 763 MP_BigRealOps_t *ops, MP_BigNumFormat_t format)); 763 764 EXTERN MP_Status_t open_logfile _ANSI_ARGS_((MP_ENV env)); 764 765 #endif /* _MP_Env_h */ 765 766 … … 1425 1426 #define MP_LISTEN_MODE 2 1426 1427 #define MP_LAUNCH_MODE 3 1428 #define MP_FORK_MODE 4 1427 1429 1428 1430 /* Initial port for listening */ … … 1456 1458 char *peerhost; 1457 1459 char *myhost; 1460 char isparent; 1458 1461 } MP_TCP_t; 1459 1462 -
MP/MP/MP_Env.c
r4f9ae6 r61941e2 57 57 58 58 #ifndef lint 59 static char vcid[] = "@(#) $Id: MP_Env.c,v 1. 1.1.1 1997-05-25 20:31:46obachman Exp $";59 static char vcid[] = "@(#) $Id: MP_Env.c,v 1.2 1997-06-05 16:38:52 obachman Exp $"; 60 60 #endif /*lint */ 61 61 … … 183 183 184 184 /* Store the log file name. */ 185 env->logfilename = IMP_ MemAllocFnc(strlen(fname) + 1);185 env->logfilename = IMP_RawMemAllocFnc(strlen(fname) + 1); 186 186 if (env->logfilename == NULL) { 187 187 fprintf(stderr, "MP_InitializeEnv: can't allocate memory!!\n"); … … 346 346 fprintf(env->logfd, "\nReleasing MP environment resources. \n"); 347 347 fclose(env->logfd); 348 IMP_ MemFreeFnc(env->logfilename, strlen(env->logfilename));348 IMP_RawMemFreeFnc(env->logfilename); 349 349 #endif 350 350 … … 495 495 496 496 #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); 498 498 fflush(stderr); 499 499 #endif -
MP/MP/MP_Get.c
r4f9ae6 r61941e2 66 66 67 67 #ifndef lint 68 static char vcid[] = "@(#) $Id: MP_Get.c,v 1. 1.1.1 1997-05-25 20:31:46obachman Exp $";68 static char vcid[] = "@(#) $Id: MP_Get.c,v 1.2 1997-06-05 16:38:54 obachman Exp $"; 69 69 #endif /* lint */ 70 70 … … 177 177 #endif 178 178 { 179 unsigned char t; 180 MP_Status_t status; 179 181 #ifdef MP_DEBUG 180 182 fprintf(stderr, "IMP_GetNodeHeader: entering for link %d\n", link->link_id); 181 183 #endif 182 unsigned char t;183 MP_Status_t status;184 184 /* 185 185 * For now we don't let the programmer in on this little secret (unless, -
MP/MP/MP_GmpBigInt.c
r4f9ae6 r61941e2 48 48 #endif 49 49 { 50 mpz_ptr apint = (mpz_ptr) mp_apint; 50 51 #ifdef MP_DEBUG 51 52 fprintf(stderr, "IMP_PutGmpInt: entering\n"); fflush(stderr); 52 53 #endif 53 mpz_ptr apint = (mpz_ptr) mp_apint;54 54 55 55 if (!IMP_PutLong(link, (long *)&(apint->_mp_size))) -
MP/MP/MP_TcpTransp.c
r4f9ae6 r61941e2 74 74 75 75 #ifndef lint 76 static char vcid[] = "@(#) $Id: MP_TcpTransp.c,v 1. 1.1.1 1997-05-25 20:31:47obachman Exp $";76 static char vcid[] = "@(#) $Id: MP_TcpTransp.c,v 1.2 1997-06-05 16:38:56 obachman Exp $"; 77 77 #endif /* lint */ 78 78 … … 179 179 else if (!strcmp(cmode, "launch")) 180 180 return MP_LAUNCH_MODE; 181 else if (!strcmp(cmode, "fork")) 182 return MP_FORK_MODE; 183 181 184 182 185 #ifdef MP_DEBUG … … 613 616 614 617 /*********************************************************************** 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__ 627 MP_Status_t open_tcp_fork_mode(MP_Link_pt link, int argc, char** argv) 628 #else 629 MP_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 /*********************************************************************** 615 729 * FUNCTION: open_tcp_connect_mode 616 730 * INPUT: link - pointer to link structure for this connection … … 878 992 printf("tcp_get_status: entering for link %d\n", link->link_id); 879 993 #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 } 880 1001 881 1002 FD_ZERO(&mask); … … 1122 1243 tcp_rec->myhost = NULL; 1123 1244 tcp_rec->peerhost = NULL; 1245 tcp_rec->isparent = 0; 1124 1246 1125 1247 link->transp.private1 = (char *)tcp_rec; … … 1132 1254 RETURN_OK(link); 1133 1255 } 1134 1135 1136 1256 1137 1257 /*********************************************************************** … … 1238 1358 break; 1239 1359 1360 case MP_FORK_MODE: 1361 status = open_tcp_fork_mode(link, argc, argv); 1362 break; 1363 1240 1364 default: 1241 1365 MP_LogEvent(link, MP_ERROR_EVENT, -
MP/MP/Makefile.in
r4f9ae6 r61941e2 119 119 rm -f MP.h 120 120 121 MP.h: ${HEADERS} 121 MP.h: ${HEADERS} 122 122 perl ./makeheader.pl -I${hdir} ${hdir}/MP.h MP.h 123 123 -
MP/MP/h/ChangeLog
r4f9ae6 r61941e2 1 Thu 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 1 5 Sun May 25 11:11:47 1997 Simon Gray (sgray@Pooh) 2 6 -
MP/MP/h/MP_Config.h.in
r4f9ae6 r61941e2 52 52 #undef HAVE_SYS_SELECT_H 53 53 54 /* Define if you have BIG ENDIAN numbers */ 55 #ifndef WORDS_BIGENDIAN 56 #undef WORDS_BIGENDIAN 57 #endif 58 54 59 /* Define to turn off logging */ 55 60 #undef NO_LOGGING -
MP/MP/h/MP_Env.h
r4f9ae6 r61941e2 118 118 EXTERN MP_Status_t MP_SetEnvBigRealFormat _ANSI_ARGS_((MP_Env_t *env, 119 119 MP_BigRealOps_t *ops, MP_BigNumFormat_t format)); 120 120 EXTERN MP_Status_t open_logfile _ANSI_ARGS_((MP_ENV env)); 121 121 #endif /* _MP_Env_h */ -
MP/MP/h/MP_TcpTransp.h
r4f9ae6 r61941e2 63 63 #define MP_LISTEN_MODE 2 64 64 #define MP_LAUNCH_MODE 3 65 #define MP_FORK_MODE 4 65 66 66 67 /* Initial port for listening */ … … 94 95 char *peerhost; 95 96 char *myhost; 97 char isparent; 96 98 } MP_TCP_t; 97 99 -
MP/MP/h/MP_Types.h
r4f9ae6 r61941e2 36 36 37 37 /* For checking the status of a link*/ 38 enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting}; 38 enum link_status_option {MP_LinkReadyReading, MP_LinkReadyWriting, 39 MP_LinkIsParent}; 39 40 typedef enum link_status_option MP_LinkStatus_t; 40 41
Note: See TracChangeset
for help on using the changeset viewer.