108 |
|
} *pslot; /* process slots */ |
109 |
|
int npslots; /* number of process slots */ |
110 |
|
|
111 |
– |
int lastpid; /* ID of last completed background process */ |
112 |
– |
PSERVER *lastpserver; /* last process server used */ |
113 |
– |
|
111 |
|
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
112 |
|
|
113 |
|
struct pslot *findpslot(); |
114 |
|
|
115 |
+ |
PSERVER *lastpserver; /* last process server with error */ |
116 |
+ |
|
117 |
|
VIEW *getview(); |
118 |
|
char *getexp(); |
119 |
|
|
481 |
|
i = sscanf(vval(RESOLUTION), "%d %d %f", &xres, &yres, &pa); |
482 |
|
mult = vflt(OVERSAMP); |
483 |
|
if (i == 3) { |
484 |
< |
sprintf(rresopt, "-x %d -y %d -pa %f", (int)(mult*xres), |
484 |
> |
sprintf(rresopt, "-x %d -y %d -pa %.3f", (int)(mult*xres), |
485 |
|
(int)(mult*yres), pa); |
486 |
< |
sprintf(fresopt, "-x %d -y %d -pa %f", xres, yres, pa); |
486 |
> |
sprintf(fresopt, "-x %d -y %d -pa %.3f", xres, yres, pa); |
487 |
|
} else if (i) { |
488 |
|
if (i == 1) yres = xres; |
489 |
|
sprintf(rresopt, "-x %d -y %d", (int)(mult*xres), |
986 |
|
} |
987 |
|
while (n > viewnum) { /* scan to desired view */ |
988 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
989 |
< |
return(viewnum==1 ? &curview : NULL); |
989 |
> |
return(viewnum==1 ? &curview : (VIEW *)NULL); |
990 |
|
if (isview(linebuf) && sscanview(&curview, linebuf) > 0) |
991 |
|
viewnum++; |
992 |
|
} |
1100 |
|
int status; |
1101 |
|
{ |
1102 |
|
register PROC *pp; |
1103 |
+ |
register struct pslot *psl; |
1104 |
|
|
1105 |
|
pp = ps->proc + pn; |
1106 |
|
if (pp->elen) { /* pass errors */ |
1112 |
|
if (ps->hostname[0]) |
1113 |
|
status = 1; /* because rsh doesn't return status */ |
1114 |
|
} |
1115 |
+ |
lastpserver = NULL; |
1116 |
+ |
psl = findpslot(pp->pid); /* check for bruncom() slot */ |
1117 |
+ |
if (psl->pid) { |
1118 |
+ |
if (status) { |
1119 |
+ |
if (psl->rcvf != NULL) /* attempt recovery */ |
1120 |
+ |
status = (*psl->rcvf)(psl->fout); |
1121 |
+ |
if (status) { |
1122 |
+ |
fprintf(stderr, |
1123 |
+ |
"%s: error rendering frame %d\n", |
1124 |
+ |
progname, psl->fout); |
1125 |
+ |
quit(1); |
1126 |
+ |
} |
1127 |
+ |
lastpserver = ps; |
1128 |
+ |
} |
1129 |
+ |
psl->pid = 0; /* free process slot */ |
1130 |
+ |
} else if (status) |
1131 |
+ |
lastpserver = ps; |
1132 |
|
freestr(pp->com); /* free command string */ |
1116 |
– |
lastpid = pp->pid; /* record PID for bwait() */ |
1117 |
– |
lastpserver = ps; /* record server for serverdown() */ |
1133 |
|
return(status); |
1134 |
|
} |
1135 |
|
|
1137 |
|
int |
1138 |
|
serverdown() /* check status of last process server */ |
1139 |
|
{ |
1140 |
+ |
if (lastpserver == NULL || !lastpserver->hostname[0]) |
1141 |
+ |
return(0); |
1142 |
|
if (pserverOK(lastpserver)) /* server still up? */ |
1143 |
|
return(0); |
1144 |
|
delpserver(lastpserver); /* else delete it */ |
1165 |
|
printf("\t%s\n", com); /* echo command */ |
1166 |
|
return(0); |
1167 |
|
} |
1168 |
< |
/* else start it when we can */ |
1169 |
< |
while ((pid = startjob(NULL, savestr(com), donecom)) == -1) |
1168 |
> |
com = savestr(com); /* else start it when we can */ |
1169 |
> |
while ((pid = startjob(NULL, com, donecom)) == -1) |
1170 |
|
bwait(1); |
1171 |
|
if (!silent) { /* echo command */ |
1172 |
|
PSERVER *ps; |
1188 |
|
int ncoms; |
1189 |
|
{ |
1190 |
|
int status; |
1174 |
– |
register struct pslot *psl; |
1191 |
|
|
1192 |
|
if (noaction) |
1193 |
|
return; |
1194 |
|
while ((status = wait4job(NULL, -1)) != -1) { |
1195 |
< |
psl = findpslot(lastpid); |
1196 |
< |
if (status) { /* attempt recovery */ |
1197 |
< |
serverdown(); /* check server */ |
1182 |
< |
if (psl->rcvf == NULL || (*psl->rcvf)(psl->fout)) { |
1183 |
< |
fprintf(stderr, |
1184 |
< |
"%s: error rendering frame %d\n", |
1185 |
< |
progname, psl->fout); |
1186 |
< |
quit(1); |
1187 |
< |
} |
1188 |
< |
} |
1189 |
< |
psl->pid = 0; /* free process slot */ |
1190 |
< |
if (!--ncoms) |
1191 |
< |
return; /* done enough */ |
1195 |
> |
serverdown(); /* update server status */ |
1196 |
> |
if (--ncoms == 0) |
1197 |
> |
break; /* done enough */ |
1198 |
|
} |
1199 |
|
} |
1200 |
|
|
1206 |
|
{ |
1207 |
|
int retstatus = 0; |
1208 |
|
int hostcopies; |
1209 |
< |
char com1buf[10240], *com1, *endcom1; |
1209 |
> |
char buf[10240], *com1, *s; |
1210 |
|
int status; |
1211 |
+ |
int pfd; |
1212 |
+ |
register int n; |
1213 |
|
register PSERVER *ps; |
1214 |
|
|
1215 |
|
if (!silent) |
1221 |
|
for (ps = pslist; ps != NULL; ps = ps->next) { |
1222 |
|
hostcopies = 0; |
1223 |
|
if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { |
1224 |
< |
strcpy(com1=com1buf, com); /* build -PP command */ |
1224 |
> |
strcpy(com1=buf, com); /* build -PP command */ |
1225 |
|
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1226 |
|
vval(DIRECTORY), phostname(ps)); |
1227 |
|
strcat(com1, ppins); |
1228 |
< |
endcom1 = com1 + strlen(com1); |
1221 |
< |
sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`", |
1222 |
< |
vval(DIRECTORY), phostname(ps)); |
1223 |
< |
} else { |
1228 |
> |
} else |
1229 |
|
com1 = com; |
1230 |
< |
endcom1 = NULL; |
1230 |
> |
while (maxcopies > 0) { |
1231 |
> |
s = savestr(com1); |
1232 |
> |
if (startjob(ps, s, donecom) != -1) { |
1233 |
> |
sleep(20); |
1234 |
> |
hostcopies++; |
1235 |
> |
maxcopies--; |
1236 |
> |
} else { |
1237 |
> |
freestr(s); |
1238 |
> |
break; |
1239 |
> |
} |
1240 |
|
} |
1227 |
– |
while (maxcopies > 0 && |
1228 |
– |
startjob(ps, savestr(com1), donecom) != -1) { |
1229 |
– |
sleep(10); |
1230 |
– |
hostcopies++; |
1231 |
– |
maxcopies--; |
1232 |
– |
if (endcom1 != NULL) |
1233 |
– |
*endcom1 = '\0'; |
1234 |
– |
} |
1241 |
|
if (!silent && hostcopies) { |
1242 |
|
if (hostcopies > 1) |
1243 |
|
printf("\t%d duplicate processes", hostcopies); |
1249 |
|
} |
1250 |
|
/* wait for jobs to finish */ |
1251 |
|
while ((status = wait4job(NULL, -1)) != -1) |
1252 |
< |
if (status) |
1253 |
< |
retstatus += !serverdown(); /* check server */ |
1252 |
> |
retstatus += status && !serverdown(); |
1253 |
> |
/* terminate parallel rpict's */ |
1254 |
> |
for (ps = pslist; ps != NULL; ps = ps->next) { |
1255 |
> |
sprintf(buf, "%s/%s.persist", vval(DIRECTORY), phostname(ps)); |
1256 |
> |
if ((pfd = open(buf, O_RDONLY)) >= 0) { |
1257 |
> |
n = read(pfd, buf, sizeof(buf)-1); /* get PID */ |
1258 |
> |
buf[n] = '\0'; |
1259 |
> |
close(pfd); |
1260 |
> |
for (n = 0; buf[n] && !isspace(buf[n]); n++) |
1261 |
> |
; |
1262 |
> |
/* terminate */ |
1263 |
> |
sprintf(buf, "kill -ALRM %d", atoi(buf+n)); |
1264 |
> |
wait4job(ps, startjob(ps, buf, NULL)); |
1265 |
> |
} |
1266 |
> |
} |
1267 |
|
return(retstatus); |
1268 |
|
} |
1269 |
|
|