--- ray/src/rt/raypcalls.c 2005/12/21 17:36:06 2.14 +++ ray/src/rt/raypcalls.c 2008/02/08 18:27:31 2.18 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: raypcalls.c,v 2.14 2005/12/21 17:36:06 greg Exp $"; +static const char RCSid[] = "$Id: raypcalls.c,v 2.18 2008/02/08 18:27:31 greg Exp $"; #endif /* * raypcalls.c - interface for parallel rendering using Radiance @@ -131,13 +131,11 @@ static const char RCSid[] = "$Id: raypcalls.c,v 2.14 2 * process should not be compromised. */ -#include -#include -#include /* XXX platform */ - #include "rtprocess.h" #include "ray.h" #include "ambient.h" +#include +#include #include "selcall.h" #ifndef RAYQLEN @@ -295,6 +293,9 @@ ray_presult( /* check for a completed ray */ /* check queued results first */ if (r_recv_first < r_recv_next) { *r = r_queue[r_recv_first++]; + /* make sure send queue has room */ + if (sendq_full() && ray_pflush() <= 0) + return(-1); return(1); } n = ray_pnprocs - ray_pnidle; /* pending before flush? */ @@ -308,6 +309,9 @@ ray_presult( /* check for a completed ray */ n = ray_pnprocs - ray_pnidle; if (n <= 0) /* return if nothing to await */ return(0); + if (!poll && ray_pnprocs == 1) /* one process -> skip select() */ + FD_SET(r_proc[0].fd_recv, &readset); + getready: /* any children waiting for us? */ for (pn = ray_pnprocs; pn--; ) if (FD_ISSET(r_proc[pn].fd_recv, &readset) || @@ -396,6 +400,8 @@ ray_pchild( /* process rays (never returns) */ { int n; register int i; + /* flag child process for quit() */ + ray_pnprocs = -1; /* read each ray request set */ while ((n = read(fd_in, (char *)r_queue, sizeof(r_queue))) > 0) { int n2; @@ -519,5 +525,7 @@ void quit(ec) /* make sure exit is called */ int ec; { + if (ray_pnprocs > 0) /* close children if any */ + ray_pclose(0); exit(ec); }