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.32 by greg, Thu Apr 30 19:30:48 2020 UTC vs.
Revision 2.39 by greg, Tue Jul 2 23:54:16 2024 UTC

# Line 212 | Line 212 | ray_pflush(void)                       /* send queued rays to idle childre
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 */
# Line 348 | Line 348 | getready:                              /* any children waiting for us? */
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);
# Line 435 | Line 435 | ray_pchild(    /* process rays (never returns) */
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          }
# Line 456 | Line 456 | ray_popen(                     /* open the specified # processes */
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 */
# Line 510 | Line 512 | ray_pclose(            /* close one or more child processes */
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++)
# Line 537 | Line 544 | ray_pclose(            /* close one or more child processes */
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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines