--- ray/src/hd/rholo2l.c 1997/11/24 15:18:47 3.5 +++ ray/src/hd/rholo2l.c 1998/01/20 15:04:23 3.11 @@ -10,20 +10,22 @@ static char SCCSid[] = "$SunId$ SGI"; #include "rholo.h" #include "random.h" +#include "paths.h" #include "selcall.h" #include #include #ifndef MAXPROC -#define MAXPROC 16 +#define MAXPROC 64 #endif -static char PFILE[] = "/usr/tmp/RHpersist"; /* persist file name */ +int nprocs = 0; /* running process count */ +static char pfile[] = TEMPLATE; /* persist file name */ + static int rtpd[MAXPROC][3]; /* process descriptors */ static float *rtbuf = NULL; /* allocated i/o buffer */ static int maxqlen = 0; /* maximum packets per queue */ -static int nprocs = 0; /* number of processes */ static PACKET *pqueue[MAXPROC]; /* packet queues */ static int pqlen[MAXPROC]; /* packet queue lengths */ @@ -34,35 +36,39 @@ start_rtrace() /* start rtrace process */ { static char buf1[8]; int rmaxpack = 0; - int psiz, npt, n; + int psiz, n; /* get number of processes */ - if ((npt = ncprocs) <= 0) + if (ncprocs <= 0 || nprocs > 0) return(0); - if (npt > MAXPROC) { + if (ncprocs > MAXPROC) { sprintf(errmsg, "number of rtrace processes reduced from %d to %d", - npt, MAXPROC); + ncprocs, MAXPROC); error(WARNING, errmsg); - npt = MAXPROC; + ncprocs = MAXPROC; } - /* add compulsory options */ - rtargv[rtargc++] = "-i-"; - rtargv[rtargc++] = "-I-"; - rtargv[rtargc++] = "-h-"; - rtargv[rtargc++] = "-ld-"; - sprintf(buf1, "%d", RPACKSIZ); - rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1; - rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0"; - rtargv[rtargc++] = "-fff"; - rtargv[rtargc++] = "-ovL"; - rtargv[rtargc++] = nowarn ? "-w-" : "-w+"; - if (npt > 1) { - rtargv[rtargc++] = "-PP"; rtargv[rtargc++] = PFILE; + if (rtargv[rtargc-1] != vval(OCTREE)) { + /* add compulsory options */ + rtargv[rtargc++] = "-i-"; + rtargv[rtargc++] = "-I-"; + rtargv[rtargc++] = "-h-"; + rtargv[rtargc++] = "-ld-"; + sprintf(buf1, "%d", RPACKSIZ); + rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1; + rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0"; + rtargv[rtargc++] = "-fff"; + rtargv[rtargc++] = vbool(VDIST) ? "-ovl" : "-ovL"; + if (nowarn) + rtargv[rtargc++] = "-w-"; + if (ncprocs > 1) { + mktemp(pfile); + rtargv[rtargc++] = "-PP"; rtargv[rtargc++] = pfile; + } + rtargv[rtargc++] = vval(OCTREE); + rtargv[rtargc] = NULL; } - rtargv[rtargc++] = vval(OCTREE); - rtargv[rtargc] = NULL; maxqlen = 0; - for (nprocs = 0; nprocs < npt; nprocs++) { /* spawn children */ + for (nprocs = 0; nprocs < ncprocs; nprocs++) { /* spawn children */ psiz = open_process(rtpd[nprocs], rtargv); if (psiz <= 0) error(SYSTEM, "cannot start rtrace process"); @@ -71,6 +77,7 @@ start_rtrace() /* start rtrace process */ if (!(maxqlen = n)) error(INTERNAL, "bad pipe buffer size assumption"); + sleep(2); } else if (n != maxqlen) error(INTERNAL, "varying pipe buffer size!"); rmaxpack += n; @@ -291,10 +298,10 @@ killpersist() /* kill persistent process */ FILE *fp; int pid; - if ((fp = fopen(PFILE, "r")) == NULL) + if ((fp = fopen(pfile, "r")) == NULL) return; if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0) - unlink(PFILE); + unlink(pfile); fclose(fp); }