Changeset f47847f in git
- Timestamp:
- Sep 21, 2010, 7:02:05 PM (13 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- 2cc567ccdbc100de452f04837e7b0808bd32a390
- Parents:
- cf3808042943877e2ddb788b8ee0457117d4f891
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ssiLink.cc
rcf3808 rf47847f 47 47 } ssiInfo; 48 48 49 50 typedef struct 51 { 52 leftv u; 53 si_link l; 54 void * next; 55 } link_struct; 56 57 typedef link_struct* link_list; 58 59 link_list ssiToBeClosed=NULL; 60 49 61 // the helper functions: 50 62 void ssiSetCurrRing(const ring r) … … 492 504 if (strcmp(mode,"fork")==0) 493 505 { 506 link_list n=(link_list)omAlloc(sizeof(link_struct)); 507 n->u=u; 508 n->l=l; 509 n->next=(void *)ssiToBeClosed; 510 ssiToBeClosed=n; 511 494 512 int pc[2]; 495 513 int cp[2]; … … 499 517 if (pid==0) /*child*/ 500 518 { 519 link_list hh=ssiToBeClosed; 520 while(hh!=NULL) 521 { 522 if (hh->l!=l) 523 { 524 ssiInfo *dd=(ssiInfo*)hh->l->data; 525 fclose(dd->f_read); 526 fclose(dd->f_write); 527 if (dd->r!=NULL) rKill(dd->r); 528 omFreeSize((ADDRESS)dd,(sizeof *dd)); 529 hh->l->data=NULL; 530 SI_LINK_SET_CLOSE_P(hh->l); 531 } 532 hh=(link_list)hh->next; 533 } 501 534 close(pc[1]); close(cp[0]); 502 535 d->f_read=fdopen(pc[0],"r"); … … 510 543 myynest=0; 511 544 fe_fgets_stdin=fe_fgets_dummy; 512 513 514 515 516 545 if ((u!=NULL)&&(u->rtyp==IDHDL)) 546 { 547 idhdl h=(idhdl)u->data; 548 h->lev=0; 549 } 517 550 loop 518 551 { … … 685 718 struct sockaddr_in serv_addr; 686 719 struct hostent *server; 687 720 688 721 sscanf(l->name,"%255[^:]:%d",host,&portno); 689 722 //Print("connect to host %s, port %d\n",host,portno);mflush(); … … 697 730 serv_addr.sin_family = AF_INET; 698 731 memcpy((char *)&serv_addr.sin_addr.s_addr, 699 732 (char *)server->h_addr, 700 733 server->h_length); 701 734 serv_addr.sin_port = htons(portno); 702 735 if (connect(sockfd,(sockaddr*)&serv_addr,sizeof(serv_addr)) < 0) 703 736 { WerrorS("ERROR connecting"); return TRUE; } 704 737 //PrintS("connected\n");mflush(); 705 738 d->f_read=fdopen(sockfd,"r"); 706 739 d->fd_read=sockfd; … … 708 741 d->fd_write=sockfd; 709 742 SI_LINK_SET_RW_OPEN_P(l); 710 743 omFree(host); 711 744 } 712 745 else … … 764 797 { 765 798 fprintf(d->f_write,"99\n");fflush(d->f_write); 799 link_list hh=ssiToBeClosed; 800 if (hh->l==l) 801 { 802 ssiToBeClosed=(link_list)hh->next; 803 omFreeSize(hh,sizeof(link_struct)); 804 } 805 else while(hh!=NULL) 806 { 807 link_list hhh=(link_list)hh->next; 808 if (hhh->l==l) 809 { 810 hh->next=hhh->next; 811 omFreeSize(hhh,sizeof(link_struct)); 812 break; 813 } 814 hh=(link_list)hh->next; 815 } 766 816 } 767 817 if (d->f_read!=NULL) fclose(d->f_read); … … 884 934 { 885 935 case NONE/* nothing*/:fprintf(d->f_write,"16 "); 886 936 break; 887 937 case STRING_CMD: fprintf(d->f_write,"2 "); 888 938 ssiWriteString(d,(char *)dd); … … 1062 1112 int s= select(max_fd, &mask, NULL, NULL, wt_ptr); 1063 1113 if (s==-1) return -2; /*error*/ 1064 if (s==0) 1114 if (s==0) 1065 1115 { 1066 1116 return -1; /*poll: not ready */
Note: See TracChangeset
for help on using the changeset viewer.