Changeset 7a81686 in git
- Timestamp:
- Mar 8, 2011, 3:35:04 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- cf29d0c4a67afdf6039daded7f0bcbd17622873a
- Parents:
- 8a9bcca97de899994799612c3fb8014a6b008467
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/iparith.cc
r8a9bcca r7a81686 3198 3198 static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v) 3199 3199 { 3200 // input: u: a list with links of type 3201 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch 3202 // v: timeout for select in seconds 3203 // or 0 for polling 3204 // returns: ERROR (via Werror): timeout negative 3205 // 0: timeout (or polling): none ready 3206 // i>0: (at least) L[i] is ready 3200 3207 lists Lforks = (lists)u->Data(); 3201 3208 int t = (int)(long)v->Data(); 3209 if(t < 0) 3210 { 3211 WerrorS("negative timeout"); return TRUE; 3212 } 3202 3213 int i = slStatusSsiL(Lforks, t*1000); 3203 if ( i < 0 ) i = 0;3204 3214 res->data = (void*)(long)i; 3205 3215 return FALSE; … … 3207 3217 static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v) 3208 3218 { 3209 /* returns 1 iff all forks are finished; 0 otherwise */ 3210 lists Lforks = (lists)u->Data(); 3219 // input: u: a list with links of type 3220 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch 3221 // v: timeout for select in seconds 3222 // or 0 for polling 3223 // returns: ERROR (via Werror): timeout negative 3224 // 0: timeout (or polling): none ready 3225 // 1: all links are ready 3226 lists Lforks = (lists)u->CopyD(); 3211 3227 int timeout = 1000*(int)(long)v->Data(); 3212 lists oneFork=(lists)omAllocBin(slists_bin); 3213 oneFork->Init(1); 3228 if(timeout < 0) 3229 { 3230 WerrorS("negative timeout"); return TRUE; 3231 } 3232 int t = getRTimer()/timer_resolution; 3214 3233 int i; 3215 int t = getTimer();3216 3234 int ret = 1; 3217 for (int j = 0; j <= Lforks->nr; j++) 3218 { 3219 oneFork->m[0].Copy(&Lforks->m[j]); 3220 i = slStatusSsiL(oneFork, timeout); 3221 if (i == 1) 3222 { 3223 timeout = timeout - getTimer() + t; 3224 } 3225 else { ret = 0; j = Lforks->nr+1; /* terminate the for loop */ } 3226 omFreeSize((ADDRESS)oneFork->m,sizeof(sleftv)); 3227 } 3228 omFreeBin((ADDRESS)oneFork, slists_bin); 3235 for(int nfinished = 0; nfinished < Lforks->nr; nfinished++) 3236 { 3237 i = slStatusSsiL(Lforks, timeout); 3238 if(i > 0) 3239 { 3240 Lforks->m[i-1].CleanUp(); 3241 Lforks->m[i-1].rtyp=DEF_CMD; 3242 Lforks->m[i-1].data=NULL; 3243 timeout = si_max(0,timeout - getRTimer()/timer_resolution + t); 3244 } 3245 else { ret = 0; break; /* terminate the for loop */ } 3246 } 3247 Lforks->Clean(); 3229 3248 res->data = (void*)(long)ret; 3230 3249 return FALSE; … … 4597 4616 BOOLEAN jjWAIT1ST1(leftv res, leftv a) 4598 4617 { 4618 // input: a: a list with links of type 4619 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch 4620 // returns: i>0: (at least) a[i] is ready 4599 4621 lists Lforks = (lists)a->Data(); 4600 4622 int i = slStatusSsiL(Lforks, -1); 4601 while (i <= 0) i = slStatusSsiL(Lforks, 10000000); /* redo this all 10 seconds */4602 4623 res->data = (void*)(long)i; 4603 4624 return FALSE; … … 4605 4626 BOOLEAN jjWAITALL1(leftv res, leftv a) 4606 4627 { 4607 lists Lforks = (lists)a->Data(); 4608 lists oneFork=(lists)omAllocBin(slists_bin); 4609 oneFork->Init(1); 4628 // input: a: a list with links of type 4629 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch 4630 // returns: nothing. All links are ready when finished. 4631 lists Lforks = (lists)u->CopyD(); 4610 4632 int i; 4611 for (int j = 0; j <= Lforks->nr; j++)4612 { 4613 oneFork->m[0].Copy(&Lforks->m[j]);4614 i = slStatusSsiL(oneFork, -1);4615 while (i != 1) i = slStatusSsiL(oneFork, 10000000); /* redo this all 10 seconds */4616 omFreeSize((ADDRESS)oneFork->m,sizeof(sleftv));4617 } 4618 omFreeBin((ADDRESS)oneFork, slists_bin);4633 for(int nfinished = 0; nfinished < Lforks->nr; nfinished++) 4634 { 4635 i = slStatusSsiL(Lforks, -1); 4636 Lforks->m[i-1].CleanUp(); 4637 Lforks->m[i-1].rtyp=DEF_CMD; 4638 Lforks->m[i-1].data=NULL; 4639 } 4640 Lforks->Clean(); 4619 4641 return FALSE; 4620 4642 } -
Singular/ssiLink.cc
r8a9bcca r7a81686 1218 1218 for(i=L->nr; i>=0; i--) 1219 1219 { 1220 if (L->m[i].Typ()!=LINK_CMD) 1221 { WerrorS("all elements must be of type link"); return -2;} 1222 l=(si_link)L->m[i].Data(); 1223 if(SI_LINK_OPEN_P(l)==0) 1224 { WerrorS("all links must be open"); return -2;} 1225 if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0)) 1226 || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0) 1227 && (strcmp(l->mode,"launch")!=0))) 1228 { 1229 WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork or MPtcp:launch"); 1230 return -2; 1231 } 1220 if (L->m[i].Typ()!=DEF_CMD) 1221 { 1222 if (L->m[i].Typ()!=LINK_CMD) 1223 { WerrorS("all elements must be of type link"); return -2;} 1224 l=(si_link)L->m[i].Data(); 1225 if(SI_LINK_OPEN_P(l)==0) 1226 { WerrorS("all links must be open"); return -2;} 1227 if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0)) 1228 || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0) 1229 && (strcmp(l->mode,"launch")!=0))) 1230 { 1231 WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork or MPtcp:launch"); 1232 return -2; 1233 } 1232 1234 #ifdef HAVE_MPSR 1233 if (strcmp(l->m->type,"ssi")==0) 1234 { 1235 if (strcmp(l->m->type,"ssi")==0) 1236 { 1237 d=(ssiInfo*)l->data; 1238 d_fd=d->fd_read; 1239 } 1240 else 1241 { 1242 dd=(MP_Link_pt)l->data; 1243 d_fd=((MP_TCP_t *)dd->transp.private1)->sock; 1244 } 1245 #else 1235 1246 d=(ssiInfo*)l->data; 1236 1247 d_fd=d->fd_read; 1237 }1238 else1239 {1240 dd=(MP_Link_pt)l->data;1241 d_fd=((MP_TCP_t *)dd->transp.private1)->sock;1242 }1243 #else1244 d=(ssiInfo*)l->data;1245 d_fd=d->fd_read;1246 1248 #endif 1247 FD_SET(d_fd, &mask); 1248 if (d_fd > max_fd) max_fd=d_fd; 1249 FD_SET(d_fd, &mask); 1250 if (d_fd > max_fd) max_fd=d_fd; 1251 } 1249 1252 } 1250 1253 max_fd++; … … 1286 1289 for(i=L->nr; i>=0; i--) 1287 1290 { 1288 l=(si_link)L->m[i].Data(); 1289 #ifdef HAVE_MPSR 1290 if (strcmp(l->m->type,"ssi")!=0) 1291 { 1292 // for MP links, return here: 1293 dd=(MP_Link_pt)l->data; 1294 d_fd=((MP_TCP_t *)dd->transp.private1)->sock; 1295 if(j==d_fd) return i+1; 1296 } 1297 else 1298 { 1291 if (L->m[i].rtyp==LINK_CMD) 1292 { 1293 l=(si_link)L->m[i].Data(); 1294 #ifdef HAVE_MPSR 1295 if (strcmp(l->m->type,"ssi")!=0) 1296 { 1297 // for MP links, return here: 1298 dd=(MP_Link_pt)l->data; 1299 d_fd=((MP_TCP_t *)dd->transp.private1)->sock; 1300 if(j==d_fd) return i+1; 1301 } 1302 else 1303 { 1304 d=(ssiInfo*)l->data; 1305 d_fd=d->fd_read; 1306 if(j==d_fd) break; 1307 } 1308 #else 1299 1309 d=(ssiInfo*)l->data; 1300 1310 d_fd=d->fd_read; 1301 1311 if(j==d_fd) break; 1302 } 1303 #else 1304 d=(ssiInfo*)l->data; 1305 d_fd=d->fd_read; 1306 if(j==d_fd) break; 1307 #endif 1312 #endif 1313 } 1308 1314 } 1309 1315 // only ssi links:
Note: See TracChangeset
for help on using the changeset viewer.