ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raypcalls.c
(Generate patch)

Comparing ray/src/rt/raypcalls.c (file contents):
Revision 2.7 by greg, Fri Sep 17 14:27:33 2004 UTC vs.
Revision 2.12 by greg, Sat Dec 17 22:17:51 2005 UTC

# Line 43 | Line 43 | static const char      RCSid[] = "$Id$";
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 }
# Line 402 | Line 402 | ray_pchild(    /* process rays (never returns) */
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]);
# Line 468 | Line 466 | ray_popen(                     /* open the specified # processes */
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;
# Line 500 | Line 504 | ray_pclose(            /* close one or more child processes */
504                  ray_pnprocs--;
505                  close(r_proc[ray_pnprocs].fd_recv);
506                  close(r_proc[ray_pnprocs].fd_send);
507 <                while (wait(&status) != r_proc[ray_pnprocs].pid)
508 <                        ;
507 >                if (waitpid(r_proc[ray_pnprocs].pid, &status, 0) < 0)
508 >                        status = 127<<8;
509                  if (status) {
510                          sprintf(errmsg,
511                                  "rendering process %d exited with code %d",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines