Changeset 1edbcdd in git


Ignore:
Timestamp:
Mar 11, 2011, 1:38:26 PM (12 years ago)
Author:
Andreas Steenpaß <steenpas@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
240d6e0f71a7c78b7ad7e858be185c519c48c85f
Parents:
2404eaa111daafc0bf19376132cb7a10c7f21daf
Message:
handling of crashed ssi links in waitall and waitfirst

git-svn-id: file:///usr/local/Singular/svn/trunk@13953 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    r2404eaa r1edbcdd  
    32033203//           or 0 for polling
    32043204// returns: ERROR (via Werror): timeout negative
    3205 //           0: timeout (or polling): none ready
     3205//           -1: the read state of all links is eof
     3206//            0: timeout (or polling): none ready
    32063207//           i>0: (at least) L[i] is ready
    32073208  lists Lforks = (lists)u->Data();
     
    32123213  }
    32133214  int i = slStatusSsiL(Lforks, t*1000);
     3215  if(i == -2) /* error */
     3216  {
     3217    return TRUE;
     3218  }
    32143219  res->data = (void*)(long)i;
    32153220  return FALSE;
     
    32223227//           or 0 for polling
    32233228// returns: ERROR (via Werror): timeout negative
     3229//           -1: the read state of all links is eof
    32243230//           0: timeout (or polling): none ready
    32253231//           1: all links are ready
     3232//              (caution: at least one is ready, but some maybe dead)
    32263233  lists Lforks = (lists)u->CopyD();
    32273234  int timeout = 1000*(int)(long)v->Data();
     
    32323239  int t = 1000*getRTimer()/TIMER_RESOLUTION;
    32333240  int i;
    3234   int ret = 1;
    3235   for(int nfinished = 0; nfinished < Lforks->nr; nfinished++)
     3241  int ret = -1;
     3242  for(int nfinished = 0; nfinished < Lforks->nr+1; nfinished++)
    32363243  {
    32373244    i = slStatusSsiL(Lforks, timeout);
    3238     if(i > 0)
    3239     {
     3245    if(i > 0) /* Lforks[i] is ready */
     3246    {
     3247      ret = 1;
    32403248      Lforks->m[i-1].CleanUp();
    32413249      Lforks->m[i-1].rtyp=DEF_CMD;
     
    32433251      timeout = si_max(0,timeout - 1000*getRTimer()/TIMER_RESOLUTION + t);
    32443252    }
    3245     else { ret = 0; break; /* terminate the for loop */ }
     3253    else /* terminate the for loop */
     3254    {
     3255      if(i == -2) /* error */
     3256      {
     3257        return TRUE;
     3258      }
     3259      if(i == 0) /* timeout */
     3260      {
     3261        ret = 0;
     3262      }
     3263      break;
     3264    }
    32463265  }
    32473266  Lforks->Clean();
     
    46184637// input: u: a list with links of type
    46194638//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
    4620 // returns: i>0: (at least) a[i] is ready
     4639// returns: -1:  the read state of all links is eof
     4640//          i>0: (at least) u[i] is ready
    46214641  lists Lforks = (lists)u->Data();
    46224642  int i = slStatusSsiL(Lforks, -1);
     4643  if(i == -2) /* error */
     4644  {
     4645    return TRUE;
     4646  }
    46234647  res->data = (void*)(long)i;
    46244648  return FALSE;
     
    46284652// input: u: a list with links of type
    46294653//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
    4630 // returns: nothing. All links are ready when finished.
     4654// returns: -1: the read state of all links is eof
     4655//           1: all links are ready
     4656//              (caution: at least one is ready, but some maybe dead)
    46314657  lists Lforks = (lists)u->CopyD();
    46324658  int i;
    4633   for(int nfinished = 0; nfinished < Lforks->nr; nfinished++)
     4659  int j = -1;
     4660  for(int nfinished = 0; nfinished < Lforks->nr+1; nfinished++)
    46344661  {
    46354662    i = slStatusSsiL(Lforks, -1);
     4663    if(i == -2) /* error */
     4664    {
     4665      return TRUE;
     4666    }
     4667    if(i == -1)
     4668    {
     4669      break;
     4670    }
     4671    j = 1;
    46364672    Lforks->m[i-1].CleanUp();
    46374673    Lforks->m[i-1].rtyp=DEF_CMD;
    46384674    Lforks->m[i-1].data=NULL;
    46394675  }
     4676  res->data = (void*)(long)j;
    46404677  Lforks->Clean();
    46414678  return FALSE;
  • Singular/misc_ip.cc

    r2404eaa r1edbcdd  
    10591059  else
    10601060  {
    1061       printf("\nhalt %d\n",i);
     1061      if(!singular_in_batchmode)
     1062      {
     1063        printf("\nhalt %d\n",i);
     1064      }
    10621065  }
    10631066  #ifdef HAVE_MPSR
  • Singular/ssiLink.cc

    r2404eaa r1edbcdd  
    11971197{
    11981198// input: L: a list with links of type
    1199 //           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
     1199//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
     1200//           Note: Not every entry in L must be set.
    12001201//        timeout: timeout for select in micro-seconds
    12011202//           or -1 for infinity
     
    12031204// returns: ERROR (via Werror): L has wrong elements or link not open
    12041205//           -2: select returns an error
    1205 //           0: timeout or (polling): none ready
     1206//           -1: the read state of all links is eof
     1207//           0:  timeout (or polling): none ready,
    12061208//           i>0: (at least) L[i] is ready
    12071209  si_link l;
     
    12121214  int d_fd;
    12131215  fd_set  mask, fdmask;
     1216  FD_ZERO(&fdmask);
    12141217  FD_ZERO(&mask);
    1215   int max_fd=0; /* max fd in fd_set */
    1216   struct timeval wt;
     1218  int max_fd=0; /* 1 + max fd in fd_set */
     1219
     1220  /* timeout */
     1221  struct timespec wt;
     1222  int startingtime = getRTimer()/TIMER_RESOLUTION;  // in seconds
     1223  struct timespec *wt_ptr=&wt;
     1224  if (timeout== -1)
     1225  {
     1226    wt_ptr=NULL;
     1227  }
     1228  else
     1229  {
     1230    wt.tv_sec  = timeout / 1000000;
     1231    wt.tv_nsec = 1000 * (timeout % 1000000);
     1232  }
     1233
     1234  /* signal mask for pselect() */
     1235  sigset_t sigmask;
     1236  if(sigprocmask(SIG_SETMASK, NULL, &sigmask) < 0)
     1237  {
     1238    WerrorS("error in sigprocmask()");
     1239    return -2;
     1240  }
     1241  if(sigaddset(&sigmask, SIGCHLD) < 0)
     1242  {
     1243    WerrorS("error in sigaddset()");
     1244    return -2;
     1245  }
     1246
     1247  /* auxiliary variables */
    12171248  int i;
     1249  int j;
     1250  int k;
     1251  int s;
     1252  char fdmaskempty;
     1253
     1254  /* check the links and fill in fdmask */
    12181255  for(i=L->nr; i>=0; i--)
    12191256  {
     
    12291266        && (strcmp(l->mode,"launch")!=0)))
    12301267      {
    1231         WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork or MPtcp:launch");
     1268        WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork\n");
     1269        WerrorS("or MPtcp:launch");
    12321270        return -2;
    12331271      }
     
    12471285      d_fd=d->fd_read;
    12481286    #endif
    1249       FD_SET(d_fd, &mask);
     1287      FD_SET(d_fd, &fdmask);
    12501288      if (d_fd > max_fd) max_fd=d_fd;
    12511289    }
    12521290  }
    12531291  max_fd++;
    1254   struct timeval *wt_ptr=&wt;
    1255   if (timeout== -1)
    1256   {
    1257     wt_ptr=NULL;
    1258   }
    1259   else
    1260   {
    1261     wt.tv_sec  = timeout / 1000000;
    1262     wt.tv_usec = timeout % 1000000;
    1263   }
     1292
     1293do_select:
     1294  /* copy fdmask to mask */
     1295  FD_ZERO(&mask);
     1296  for(k = 0; k < max_fd; k++)
     1297  {
     1298    if(FD_ISSET(k, &fdmask))
     1299    {
     1300      FD_SET(k, &mask);
     1301    }
     1302  }
     1303
    12641304  /* check with select: chars waiting: no -> not ready */
    1265   int s= select(max_fd, &mask, NULL, NULL, wt_ptr);
     1305  s = pselect(max_fd, &mask, NULL, NULL, wt_ptr, &sigmask);
     1306Print("\nselect: %d\n", s);
    12661307  if (s==-1)
    12671308  {
     
    12691310    return -2; /*error*/
    12701311  }
    1271   int j;
    1272   int retry_needed=0;
    1273 find_next_fd:
    12741312  if (s==0)
    12751313  {
    1276     if (retry_needed)
    1277     {
    1278       // the os reported that one of the (ssi) links is ready,
    1279       // but it was only white space: this cannot happen again:
    1280       return slStatusSsiL(L,timeout);
    1281     }
    1282     else
    1283       return 0; /*poll: not ready */
     1314    return 0; /*poll: not ready */
    12841315  }
    12851316  else /* s>0, at least one ready  (the number of fd which are ready is s)*/
     
    13221353      int c=fgetc(d->f_read);
    13231354      //Print("try c=%d\n",c);
    1324       if (c== -1) /* eof or error*/
    1325       {
    1326         retry_needed=1;
    1327         FD_CLR(j,&mask);
    1328         s--;
    1329         goto find_next_fd;
    1330       }
     1355      if (c== -1) /* eof */
     1356      {
     1357        FD_CLR(j,&fdmask);
     1358        fdmaskempty = 1;
     1359        for(k = 0; k < max_fd; k++)
     1360        {
     1361          if(FD_ISSET(k, &fdmask))
     1362          {
     1363            fdmaskempty = 0;
     1364            break;
     1365          }
     1366        }
     1367        if(fdmaskempty)
     1368        {
     1369          return -1;
     1370        }
     1371        if(timeout != -1)
     1372        {
     1373          timeout = si_max(0,
     1374               timeout - 1000000*(getRTimer()/TIMER_RESOLUTION - startingtime));
     1375          wt.tv_sec  = timeout / 1000000;
     1376          wt.tv_nsec = 1000 * (timeout % 1000000);
     1377        }
     1378        goto do_select;
     1379      }
     1380
    13311381      else if (isdigit(c))
    13321382      { ungetc(c,d->f_read); d->ungetc_buf='\1'; return i+1; }
  • Singular/table.h

    r2404eaa r1edbcdd  
    282282,{D(loNewtonP),    NEWTONPOLY_CMD,  IDEAL_CMD,      IDEAL_CMD     , ALLOW_PLURAL |ALLOW_RING}
    283283,{D(jjWAIT1ST1),   WAIT1ST_CMD,     INT_CMD,        LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
    284 ,{D(jjWAITALL1),   WAITALL_CMD,     NONE,           LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
     284,{D(jjWAITALL1),   WAITALL_CMD,     INT_CMD,        LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
    285285,{NULL,             0,               0,              0             , NO_PLURAL |NO_RING}
    286286};
Note: See TracChangeset for help on using the changeset viewer.