| 147 |
|
#include "selcall.h" |
| 148 |
|
|
| 149 |
|
#ifndef RAYQLEN |
| 150 |
< |
#define RAYQLEN 12 /* # rays to send at once */ |
| 150 |
> |
#define RAYQLEN 24 /* # rays to send at once */ |
| 151 |
|
#endif |
| 152 |
|
|
| 153 |
|
#ifndef MAX_RPROCS |
| 212 |
|
for (i = ray_pnprocs; nc && i--; ) { |
| 213 |
|
if (r_proc[i].npending > 0) |
| 214 |
|
continue; /* child looks busy */ |
| 215 |
< |
n = (r_send_next - sfirst)/nc--; |
| 215 |
> |
n = (r_send_next - sfirst) / nc--; |
| 216 |
|
if (!n) |
| 217 |
|
continue; |
| 218 |
|
/* smuggle set size in crtype */ |
| 219 |
|
r_queue[sfirst].crtype = n; |
| 220 |
< |
nw = writebuf(r_proc[i].fd_send, (char *)&r_queue[sfirst], |
| 220 |
> |
nw = writebuf(r_proc[i].fd_send, &r_queue[sfirst], |
| 221 |
|
sizeof(RAY)*n); |
| 222 |
|
if (nw != sizeof(RAY)*n) |
| 223 |
|
return(-1); /* write error */ |
| 290 |
|
static struct timeval tpoll; /* zero timeval struct */ |
| 291 |
|
static fd_set readset, errset; |
| 292 |
|
int n, ok; |
| 293 |
< |
register int pn; |
| 293 |
> |
int pn; |
| 294 |
|
|
| 295 |
|
if (r == NULL) |
| 296 |
|
return(0); |
| 348 |
|
error(CONSISTENCY, "buffer shortage in ray_presult()"); |
| 349 |
|
|
| 350 |
|
/* read rendered ray data */ |
| 351 |
< |
n = readbuf(r_proc[pn].fd_recv, (char *)&r_queue[r_recv_next], |
| 351 |
> |
n = readbuf(r_proc[pn].fd_recv, &r_queue[r_recv_next], |
| 352 |
|
sizeof(RAY)*r_proc[pn].npending); |
| 353 |
|
if (n > 0) { |
| 354 |
|
r_recv_next += n/sizeof(RAY); |
| 368 |
|
} |
| 369 |
|
/* preen returned rays */ |
| 370 |
|
for (n = r_recv_next - r_recv_first; n--; ) { |
| 371 |
< |
register RAY *rp = &r_queue[r_recv_first + n]; |
| 371 |
> |
RAY *rp = &r_queue[r_recv_first + n]; |
| 372 |
|
rp->rno = r_proc[pn].rno[n]; |
| 373 |
|
rp->parent = NULL; |
| 374 |
|
rp->newcset = rp->clipset = NULL; |
| 404 |
|
) |
| 405 |
|
{ |
| 406 |
|
int n; |
| 407 |
< |
register int i; |
| 407 |
> |
int i; |
| 408 |
|
/* flag child process for quit() */ |
| 409 |
|
ray_pnprocs = -1; |
| 410 |
|
/* read each ray request set */ |
| 435 |
|
rayvalue(&r_queue[i]); |
| 436 |
|
} |
| 437 |
|
/* write back our results */ |
| 438 |
< |
i = writebuf(fd_out, (char *)r_queue, sizeof(RAY)*n); |
| 438 |
> |
i = writebuf(fd_out, r_queue, sizeof(RAY)*n); |
| 439 |
|
if (i != sizeof(RAY)*n) |
| 440 |
|
error(SYSTEM, "write error in ray_pchild()"); |
| 441 |
|
} |
| 456 |
|
nadd = MAX_NPROCS - ray_pnprocs; |
| 457 |
|
if (nadd <= 0) |
| 458 |
|
return; |
| 459 |
+ |
if (nobjects <= 0) |
| 460 |
+ |
error(CONSISTENCY, "ray_popen() called before scene loaded"); |
| 461 |
|
ambsync(); /* load any new ambient values */ |
| 462 |
|
if (shm_boundary == NULL) { /* first child process? */ |
| 463 |
|
preload_objs(); /* preload auxiliary data */ |
| 512 |
|
static int inclose = 0; |
| 513 |
|
RAY res; |
| 514 |
|
int i, status = 0; |
| 515 |
+ |
/* check no child / in child */ |
| 516 |
+ |
if (ray_pnprocs <= 0) |
| 517 |
+ |
return; |
| 518 |
|
/* check recursion */ |
| 519 |
|
if (inclose) |
| 520 |
|
return; |
| 521 |
|
inclose++; |
| 517 |
– |
/* check no child / in child */ |
| 518 |
– |
if (ray_pnprocs <= 0) |
| 519 |
– |
return; |
| 522 |
|
/* check argument */ |
| 523 |
|
if ((nsub <= 0) | (nsub > ray_pnprocs)) |
| 524 |
|
nsub = ray_pnprocs; |
| 525 |
|
/* clear our ray queue */ |
| 526 |
+ |
i = r_send_next; |
| 527 |
+ |
r_send_next = 0; |
| 528 |
|
while (ray_presult(&res,0) > 0) |
| 529 |
< |
; |
| 530 |
< |
r_send_next = 0; /* hard reset in case of error */ |
| 529 |
> |
++i; |
| 530 |
> |
if (i) { |
| 531 |
> |
sprintf(errmsg, "dropped %d rays in ray_pclose()", i); |
| 532 |
> |
error(WARNING, errmsg); |
| 533 |
> |
} |
| 534 |
|
r_recv_first = r_recv_next = RAYQLEN; |
| 535 |
|
/* close send pipes */ |
| 536 |
|
for (i = ray_pnprocs-nsub; i < ray_pnprocs; i++) |
| 544 |
|
for (i = 0; i < nsub; ) { |
| 545 |
|
int j, mystatus; |
| 546 |
|
RT_PID pid = wait(&mystatus); |
| 547 |
+ |
if (pid < 0) { |
| 548 |
+ |
status = 127<<8; |
| 549 |
+ |
break; |
| 550 |
+ |
} |
| 551 |
|
for (j = ray_pnprocs-nsub; j < ray_pnprocs; j++) |
| 552 |
|
if (r_proc[j].pid == pid) { |
| 553 |
|
if (mystatus) |