--- ray/src/rt/raypcalls.c 2007/09/15 02:47:56 2.16 +++ ray/src/rt/raypcalls.c 2008/12/02 23:28:34 2.20 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: raypcalls.c,v 2.16 2007/09/15 02:47:56 greg Exp $"; +static const char RCSid[] = "$Id: raypcalls.c,v 2.20 2008/12/02 23:28:34 greg Exp $"; #endif /* * raypcalls.c - interface for parallel rendering using Radiance @@ -131,13 +131,11 @@ static const char RCSid[] = "$Id: raypcalls.c,v 2.16 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 @@ -187,12 +185,6 @@ ray_pinit( /* initialize ray-tracing processes */ ray_init(otnm); /* load the shared scene */ - preload_objs(); /* preload auxiliary data */ - - /* set shared memory boundary */ - shm_boundary = (char *)malloc(16); - strcpy(shm_boundary, "SHM_BOUNDARY"); - r_send_next = 0; /* set up queue */ r_recv_first = r_recv_next = RAYQLEN; @@ -259,14 +251,14 @@ ray_pqueue( /* queue a ray for computation */ return(0); /* check for full send queue */ if (sendq_full()) { - RAY mySend; - int rval; - mySend = *r; + RAY mySend = *r; /* wait for a result */ - rval = ray_presult(r, 0); + if (ray_presult(r, 0) <= 0) + return(-1); /* put new ray in queue */ r_queue[r_send_next++] = mySend; - return(rval); /* done */ + /* XXX r_send_next may now be > RAYQLEN */ + return(1); } /* else add ray to send queue */ r_queue[r_send_next++] = *r; @@ -450,6 +442,12 @@ ray_popen( /* open the specified # processes */ if (nadd <= 0) return; ambsync(); /* load any new ambient values */ + if (shm_boundary == NULL) { /* first child process? */ + preload_objs(); /* preload auxiliary data */ + /* set shared memory boundary */ + shm_boundary = (char *)malloc(16); + strcpy(shm_boundary, "SHM_BOUNDARY"); + } fflush(NULL); /* clear pending output */ while (nadd--) { /* fork each new process */ int p0[2], p1[2];