43 |
|
* myRay.rorg = ( ray origin point ) |
44 |
|
* myRay.rdir = ( normalized ray direction ) |
45 |
|
* myRay.rmax = ( maximum length, or zero for no limit ) |
46 |
< |
* rayorigin(&myRay, NULL, PRIMARY, 1.0); |
46 |
> |
* rayorigin(&myRay, PRIMARY, NULL, NULL); |
47 |
|
* myRay.rno = ( my personal ray identifier ) |
48 |
|
* if (ray_pqueue(&myRay) == 1) |
49 |
|
* { do something with results } |
402 |
|
/* read each ray request set */ |
403 |
|
while ((n = read(fd_in, (char *)r_queue, sizeof(r_queue))) > 0) { |
404 |
|
int n2; |
405 |
< |
if (n % sizeof(RAY)) |
405 |
> |
if (n < sizeof(RAY)) |
406 |
|
break; |
407 |
– |
n /= sizeof(RAY); |
407 |
|
/* get smuggled set length */ |
408 |
< |
n2 = r_queue[0].crtype - n; |
408 |
> |
n2 = sizeof(RAY)*r_queue[0].crtype - n; |
409 |
|
if (n2 < 0) |
410 |
|
error(INTERNAL, "buffer over-read in ray_pchild"); |
411 |
|
if (n2 > 0) { /* read the rest of the set */ |
412 |
< |
i = readbuf(fd_in, (char *)(r_queue+n), |
413 |
< |
sizeof(RAY)*n2); |
415 |
< |
if (i != sizeof(RAY)*n2) |
412 |
> |
i = readbuf(fd_in, (char *)r_queue + n, n2); |
413 |
> |
if (i != n2) |
414 |
|
break; |
415 |
|
n += n2; |
416 |
|
} |
417 |
+ |
n /= sizeof(RAY); |
418 |
|
/* evaluate rays */ |
419 |
|
for (i = 0; i < n; i++) { |
420 |
|
r_queue[i].crtype = r_queue[i].rtype; |
421 |
|
r_queue[i].parent = NULL; |
422 |
|
r_queue[i].clipset = NULL; |
423 |
|
r_queue[i].slights = NULL; |
425 |
– |
r_queue[i].revf = raytrace; |
424 |
|
samplendx++; |
425 |
|
rayclear(&r_queue[i]); |
426 |
|
rayvalue(&r_queue[i]); |
466 |
|
if (r_proc[ray_pnprocs].pid < 0) |
467 |
|
error(SYSTEM, "cannot fork child process"); |
468 |
|
close(p1[0]); close(p0[1]); |
469 |
+ |
/* |
470 |
+ |
* Close write stream on exec to avoid multiprocessing deadlock. |
471 |
+ |
* No use in read stream without it, so set flag there as well. |
472 |
+ |
*/ |
473 |
+ |
fcntl(p1[1], F_SETFD, FD_CLOEXEC); |
474 |
+ |
fcntl(p0[0], F_SETFD, FD_CLOEXEC); |
475 |
|
r_proc[ray_pnprocs].fd_send = p1[1]; |
476 |
|
r_proc[ray_pnprocs].fd_recv = p0[0]; |
477 |
|
r_proc[ray_pnprocs].npending = 0; |