10 |
|
|
11 |
|
#include "rholo.h" |
12 |
|
#include "random.h" |
13 |
+ |
#include "paths.h" |
14 |
+ |
#include "selcall.h" |
15 |
|
#include <signal.h> |
16 |
|
#include <sys/time.h> |
17 |
|
|
18 |
|
#ifndef MAXPROC |
19 |
< |
#define MAXPROC 16 |
19 |
> |
#define MAXPROC 64 |
20 |
|
#endif |
21 |
|
|
22 |
< |
static char PFILE[] = "/usr/tmp/RHpersist"; /* persist file name */ |
22 |
> |
int nprocs = 0; /* running process count */ |
23 |
|
|
24 |
+ |
static char pfile[] = TEMPLATE; /* persist file name */ |
25 |
+ |
|
26 |
|
static int rtpd[MAXPROC][3]; /* process descriptors */ |
27 |
|
static float *rtbuf = NULL; /* allocated i/o buffer */ |
28 |
|
static int maxqlen = 0; /* maximum packets per queue */ |
25 |
– |
static int nprocs = 0; /* number of processes */ |
29 |
|
|
30 |
|
static PACKET *pqueue[MAXPROC]; /* packet queues */ |
31 |
|
static int pqlen[MAXPROC]; /* packet queue lengths */ |
56 |
|
rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1; |
57 |
|
rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0"; |
58 |
|
rtargv[rtargc++] = "-fff"; |
59 |
< |
rtargv[rtargc++] = "-ovl"; |
60 |
< |
rtargv[rtargc++] = nowarn ? "-w-" : "-w+"; |
59 |
> |
rtargv[rtargc++] = vbool(VDIST) ? "-ovl" : "-ovL"; |
60 |
> |
if (nowarn) |
61 |
> |
rtargv[rtargc++] = "-w-"; |
62 |
|
if (npt > 1) { |
63 |
< |
rtargv[rtargc++] = "-PP"; rtargv[rtargc++] = PFILE; |
63 |
> |
mktemp(pfile); |
64 |
> |
rtargv[rtargc++] = "-PP"; rtargv[rtargc++] = pfile; |
65 |
|
} |
66 |
|
rtargv[rtargc++] = vval(OCTREE); |
67 |
|
rtargv[rtargc] = NULL; |
212 |
|
if (n) /* read past end? */ |
213 |
|
error(INTERNAL, "packet sync error in get_packets"); |
214 |
|
/* take from queue */ |
215 |
< |
if (pldone = NULL) |
215 |
> |
if (pldone == NULL) |
216 |
|
pldone = plend = pqueue[pn]; |
217 |
|
else |
218 |
|
plend->next = pqueue[pn]; |
223 |
|
} |
224 |
|
return(pldone); /* return finished packets */ |
225 |
|
eoferr: |
226 |
< |
error(USER, "unexpected EOF from rtrace process"); |
226 |
> |
error(USER, "rtrace process died"); |
227 |
|
} |
228 |
|
|
229 |
|
|
257 |
|
if (pqlen[i]) { |
258 |
|
if (rpdone == NULL) { /* tack on queue */ |
259 |
|
rpdone = rpl = pqueue[i]; |
260 |
< |
n = rpl->nr; |
260 |
> |
if ((nr = rpl->nr) < RPACKSIZ) nr++; |
261 |
|
} else { |
262 |
|
rpl->next = pqueue[i]; |
263 |
< |
n = 0; |
263 |
> |
nr = 0; |
264 |
|
} |
265 |
< |
while (rpl->next != NULL) |
266 |
< |
n += (rpl = rpl->next)->nr; |
265 |
> |
while (rpl->next != NULL) { |
266 |
> |
nr += (rpl = rpl->next)->nr; |
267 |
> |
if (rpl->nr < RPACKSIZ) |
268 |
> |
nr++; /* add flush block */ |
269 |
> |
} |
270 |
|
n = readbuf(rtpd[i][0], (char *)rtbuf, |
271 |
< |
4*sizeof(float)*n); |
271 |
> |
4*sizeof(float)*nr); |
272 |
|
if (n < 0) |
273 |
|
error(SYSTEM, "read failure in flush_queue"); |
274 |
|
bp = rtbuf; /* process packets */ |
295 |
|
FILE *fp; |
296 |
|
int pid; |
297 |
|
|
298 |
< |
if ((fp = fopen(PFILE, "r")) == NULL) |
298 |
> |
if ((fp = fopen(pfile, "r")) == NULL) |
299 |
|
return; |
300 |
|
if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0) |
301 |
< |
unlink(PFILE); |
301 |
> |
unlink(pfile); |
302 |
|
fclose(fp); |
303 |
|
} |
304 |
|
|