--- ray/src/hd/rholo2l.c 2018/10/05 19:19:16 3.18 +++ ray/src/hd/rholo2l.c 2025/01/22 17:41:10 3.22 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rholo2l.c,v 3.18 2018/10/05 19:19:16 greg Exp $"; +static const char RCSid[] = "$Id: rholo2l.c,v 3.22 2025/01/22 17:41:10 greg Exp $"; #endif /* * Routines for local rtrace execution @@ -23,9 +23,9 @@ int nprocs = 0; /* running process count */ static char pfile[] = TEMPLATE; /* persist file name */ -static SUBPROC rtpd[MAXPROC]; /* process descriptors */ +static SUBPROC rtpd[MAXPROC]; /* process descriptors */ static float *rtbuf = NULL; /* allocated i/o buffer */ -static int maxqlen = 0; /* maximum packets per queue */ +static int maxqlen; /* maximum packets per queue */ static PACKET *pqueue[MAXPROC]; /* packet queues */ static int pqlen[MAXPROC]; /* packet queue lengths */ @@ -59,6 +59,7 @@ start_rtrace(void) /* start rtrace process */ rtargv[rtargc++] = "-I-"; rtargv[rtargc++] = "-h-"; rtargv[rtargc++] = "-ld-"; + rtargv[rtargc++] = "-co-"; sprintf(buf1, "%d", RPACKSIZ); rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1; rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0"; @@ -78,8 +79,8 @@ start_rtrace(void) /* start rtrace process */ psiz = open_process(&rtpd[nprocs], rtargv); if (psiz <= 0) error(SYSTEM, "cannot start rtrace process"); - n = psiz/(RPACKSIZ*6*sizeof(float)); - if (maxqlen == 0) { + n = psiz/(RPACKSIZ*6*sizeof(float)) + 1; + if (!maxqlen) { if (!(maxqlen = n)) error(INTERNAL, "bad pipe buffer size assumption"); @@ -113,7 +114,7 @@ bestout(void) /* get best process to process packet if (pqlen[i] == pqlen[pn]) cnt++; /* break ties fairly */ - if ((cnt = random() % cnt)) + if ((cnt = irandom(cnt))) for (i = pn; i < nprocs; i++) if (pqlen[i] == pqlen[pn] && !cnt--) return(i); @@ -146,7 +147,7 @@ queue_packet( /* queue up a beam packet */ packrays(rtbuf, p); if ((n = p->nr) < RPACKSIZ) /* add flush block? */ memset((char *)(rtbuf+6*n++), '\0', 6*sizeof(float)); - if (writebuf(rtpd[pn].w, (char *)rtbuf, 6*sizeof(float)*n) < 0) + if (writebuf(rtpd[pn].w, rtbuf, 6*sizeof(float)*n) < 0) error(SYSTEM, "write error in queue_packet"); p->next = NULL; if (!pqlen[pn]++) /* add it to the end of the queue */ @@ -281,8 +282,7 @@ flush_queue(void) /* empty all rtrace queues */ if (rpl->nr < RPACKSIZ) nr++; /* add flush block */ } - n = readbuf(rtpd[i].r, (char *)rtbuf, - 4*sizeof(float)*nr); + n = readbuf(rtpd[i].r, rtbuf, 4*sizeof(float)*nr); if (n < 0) error(SYSTEM, "read failure in flush_queue"); bp = rtbuf; /* process packets */