Changeset f47847f in git


Ignore:
Timestamp:
Sep 21, 2010, 7:02:05 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
Children:
2cc567ccdbc100de452f04837e7b0808bd32a390
Parents:
cf3808042943877e2ddb788b8ee0457117d4f891
Message:
a global list of ssi:fork links: ssiToBeClosed

git-svn-id: file:///usr/local/Singular/svn/trunk@13238 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/ssiLink.cc

    rcf3808 rf47847f  
    4747} ssiInfo;
    4848
     49
     50typedef struct
     51{
     52  leftv u;
     53  si_link l;
     54  void * next;
     55} link_struct;
     56
     57typedef link_struct* link_list;
     58
     59link_list ssiToBeClosed=NULL;
     60
    4961// the helper functions:
    5062void ssiSetCurrRing(const ring r)
     
    492504    if (strcmp(mode,"fork")==0)
    493505    {
     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
    494512      int pc[2];
    495513      int cp[2];
     
    499517      if (pid==0) /*child*/
    500518      {
     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        }
    501534        close(pc[1]); close(cp[0]);
    502535        d->f_read=fdopen(pc[0],"r");
     
    510543        myynest=0;
    511544        fe_fgets_stdin=fe_fgets_dummy;
    512         if ((u!=NULL)&&(u->rtyp==IDHDL))
    513         {
    514           idhdl h=(idhdl)u->data;
    515           h->lev=0;
    516         }
     545        if ((u!=NULL)&&(u->rtyp==IDHDL))
     546        {
     547          idhdl h=(idhdl)u->data;
     548          h->lev=0;
     549        }
    517550        loop
    518551        {
     
    685718      struct sockaddr_in serv_addr;
    686719      struct hostent *server;
    687  
     720
    688721      sscanf(l->name,"%255[^:]:%d",host,&portno);
    689722      //Print("connect to host %s, port %d\n",host,portno);mflush();
     
    697730        serv_addr.sin_family = AF_INET;
    698731        memcpy((char *)&serv_addr.sin_addr.s_addr,
    699               (char *)server->h_addr,
     732              (char *)server->h_addr,
    700733              server->h_length);
    701734        serv_addr.sin_port = htons(portno);
    702735        if (connect(sockfd,(sockaddr*)&serv_addr,sizeof(serv_addr)) < 0)
    703736        { WerrorS("ERROR connecting"); return TRUE; }
    704         //PrintS("connected\n");mflush();
     737        //PrintS("connected\n");mflush();
    705738        d->f_read=fdopen(sockfd,"r");
    706739        d->fd_read=sockfd;
     
    708741        d->fd_write=sockfd;
    709742        SI_LINK_SET_RW_OPEN_P(l);
    710         omFree(host);
     743        omFree(host);
    711744      }
    712745      else
     
    764797    {
    765798      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      }
    766816    }
    767817    if (d->f_read!=NULL) fclose(d->f_read);
     
    884934    {
    885935          case NONE/* nothing*/:fprintf(d->f_write,"16 ");
    886                           break;
     936                          break;
    887937          case STRING_CMD: fprintf(d->f_write,"2 ");
    888938                           ssiWriteString(d,(char *)dd);
     
    10621112  int s= select(max_fd, &mask, NULL, NULL, wt_ptr);
    10631113  if (s==-1) return -2; /*error*/
    1064   if (s==0) 
     1114  if (s==0)
    10651115  {
    10661116    return -1; /*poll: not ready */
Note: See TracChangeset for help on using the changeset viewer.