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

Comparing ray/src/rt/rc3.c (file contents):
Revision 2.11 by greg, Sat Jun 16 17:30:13 2012 UTC vs.
Revision 2.17 by greg, Thu Nov 15 15:26:52 2012 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
6   * Controlling process for multiple children
7   */
8  
9 + #include <signal.h>
10   #include "rcontrib.h"
10 #include "platform.h"
11 #include "rtprocess.h"
11   #include "selcall.h"
12  
13   #define MAXIQ           (int)(PIPE_BUF/(sizeof(FVECT)*2))
# Line 315 | Line 314 | in_rchild()
314  
315   /* Close child processes */
316   void
317 < end_children()
317 > end_children(int immed)
318   {
319          int     status;
320          
321          while (nchild > 0) {
322                  nchild--;
323 <                if ((status = close_process(&kida[nchild].pr)) > 0) {
323 > #ifdef SIGKILL
324 >                if (immed)              /* error mode -- quick exit */
325 >                        kill(kida[nchild].pr.pid, SIGKILL);
326 > #endif
327 >                if ((status = close_process(&kida[nchild].pr)) > 0 && !immed) {
328                          sprintf(errmsg,
329                                  "rendering process returned bad status (%d)",
330                                          status);
# Line 397 | Line 400 | tryagain:                              /* catch up with output? */
400   void
401   parental_loop()
402   {
403 <        static int      ignore_warning_given = 0;
401 <        int             qlimit = (accumulate == 1) ? 1 : MAXIQ-1;
403 >        const int       qlimit = (accumulate == 1) ? 1 : MAXIQ-1;
404          int             ninq = 0;
405          FVECT           orgdir[2*MAXIQ];
406          int             i, n;
# Line 410 | Line 412 | parental_loop()
412                  if (orgdir[2*ninq+1][0] == 0.0 &&       /* asking for flush? */
413                                  (orgdir[2*ninq+1][1] == 0.0) &
414                                  (orgdir[2*ninq+1][2] == 0.0)) {
415 <                        if (accumulate != 1) {
416 <                                if (!ignore_warning_given++)
417 <                                        error(WARNING,
418 <                                "dummy ray(s) ignored during accumulation\n");
419 <                                continue;
415 >                        if (ninq) {                     /* preempt our queue */
416 >                                i = next_child_nq(0);
417 >                                n = ninq;
418 >                                memset(orgdir[2*n++], 0, sizeof(FVECT)*2);
419 >                                n *= sizeof(FVECT)*2;
420 >                                if (writebuf(kida[i].pr.w, (char *)orgdir, n) != n)
421 >                                        error(SYSTEM, "pipe write error");
422 >                                kida[i].r1 = lastray+1;
423 >                                lastray += kida[i].nr = ninq;
424 >                                ninq = 0;
425                          }
426 <                        while (next_child_nq(1) >= 0)
427 <                                ;                       /* clear the queue */
428 <                        lastdone = lastray = 0;
429 <                        if ((yres <= 0) | (xres <= 0))
426 >                        if ((yres <= 0) | (xres <= 0) &&
427 >                                        (lastray+1) % accumulate == 0) {
428 >                                while (next_child_nq(1) >= 0)
429 >                                        ;               /* clear the queue */
430 >                                lastdone = lastray %= accumulate;
431                                  waitflush = 1;          /* flush next */
432 +                        }
433                          put_zero_record(++lastray);
434                  } else if (++ninq >= qlimit ||
435                              lastray/accumulate != (lastray+ninq)/accumulate) {
# Line 433 | Line 442 | parental_loop()
442                                  error(SYSTEM, "pipe write error");
443                          kida[i].r1 = lastray+1;
444                          lastray += kida[i].nr = ninq;   /* mark as busy */
436                        ninq = 0;
445                          if (lastray < lastdone) {       /* RNUMBER wrapped? */
446                                  while (next_child_nq(1) >= 0)
447                                          ;
448 <                                lastdone = lastray = 0;
448 >                                lastray -= ninq;
449 >                                lastdone = lastray %= accumulate;
450                          }
451 +                        ninq = 0;
452                  }
453                  if (raysleft && !--raysleft)
454                          break;                          /* preemptive EOI */
# Line 537 | Line 547 | feeder_loop()
547                  lastray += kida[i].nr = ninq;
548                  ninq = 0;
549          }
550 <        for (i = nchild; i--; ) {               /* get results */
551 <                close(kida[i].pr.w);
550 >        memset(orgdir, 0, sizeof(FVECT)*2);     /* get results */
551 >        for (i = nchild; i--; ) {
552 >                writebuf(kida[i].pr.w, (char *)orgdir, sizeof(FVECT)*2);
553                  queue_results(i);
554          }
555          if (recover)                            /* and from before? */
556                  queue_modifiers();
557 <        end_children();                         /* free up file descriptors */
557 >        end_children(0);                        /* free up file descriptors */
558          for (i = 0; i < nmods; i++)
559                  mod_output(out_bq->mca[i]);     /* output accumulated record */
560          end_record();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines