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

Comparing ray/src/hd/rholo2l.c (file contents):
Revision 3.5 by gregl, Mon Nov 24 15:18:47 1997 UTC vs.
Revision 3.12 by greg, Sat Feb 22 02:07:25 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1997 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines for local rtrace execution
6   */
7  
8   #include "rholo.h"
9   #include "random.h"
10 + #include "paths.h"
11   #include "selcall.h"
12   #include <signal.h>
13   #include <sys/time.h>
14  
15   #ifndef MAXPROC
16 < #define MAXPROC         16
16 > #define MAXPROC         64
17   #endif
18  
19 < static char     PFILE[] = "/usr/tmp/RHpersist"; /* persist file name */
19 > int     nprocs = 0;                             /* running process count */
20  
21 + static char     pfile[] = TEMPLATE;             /* persist file name */
22 +
23   static int      rtpd[MAXPROC][3];               /* process descriptors */
24   static float    *rtbuf = NULL;                  /* allocated i/o buffer */
25   static int      maxqlen = 0;                    /* maximum packets per queue */
26 static int      nprocs = 0;                     /* number of processes */
26  
27   static PACKET   *pqueue[MAXPROC];               /* packet queues */
28   static int      pqlen[MAXPROC];                 /* packet queue lengths */
# Line 34 | Line 33 | start_rtrace()                 /* start rtrace process */
33   {
34          static char     buf1[8];
35          int     rmaxpack = 0;
36 <        int     psiz, npt, n;
36 >        int     psiz, n;
37                                          /* get number of processes */
38 <        if ((npt = ncprocs) <= 0)
38 >        if (ncprocs <= 0 || nprocs > 0)
39                  return(0);
40 <        if (npt > MAXPROC) {
40 >        if (ncprocs > MAXPROC) {
41                  sprintf(errmsg,
42                          "number of rtrace processes reduced from %d to %d",
43 <                                npt, MAXPROC);
43 >                                ncprocs, MAXPROC);
44                  error(WARNING, errmsg);
45 <                npt = MAXPROC;
45 >                ncprocs = MAXPROC;
46          }
47 <                                        /* add compulsory options */
48 <        rtargv[rtargc++] = "-i-";
49 <        rtargv[rtargc++] = "-I-";
50 <        rtargv[rtargc++] = "-h-";
51 <        rtargv[rtargc++] = "-ld-";
52 <        sprintf(buf1, "%d", RPACKSIZ);
53 <        rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1;
54 <        rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0";
55 <        rtargv[rtargc++] = "-fff";
56 <        rtargv[rtargc++] = "-ovL";
57 <        rtargv[rtargc++] = nowarn ? "-w-" : "-w+";
58 <        if (npt > 1) {
59 <                rtargv[rtargc++] = "-PP"; rtargv[rtargc++] = PFILE;
47 >        if (rtargv[rtargc-1] != vval(OCTREE)) {
48 >                                                /* add compulsory options */
49 >                rtargv[rtargc++] = "-i-";
50 >                rtargv[rtargc++] = "-I-";
51 >                rtargv[rtargc++] = "-h-";
52 >                rtargv[rtargc++] = "-ld-";
53 >                sprintf(buf1, "%d", RPACKSIZ);
54 >                rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1;
55 >                rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0";
56 >                rtargv[rtargc++] = "-fff";
57 >                rtargv[rtargc++] = vbool(VDIST) ? "-ovl" : "-ovL";
58 >                if (nowarn)
59 >                        rtargv[rtargc++] = "-w-";
60 >                if (ncprocs > 1) {
61 >                        mktemp(pfile);
62 >                        rtargv[rtargc++] = "-PP"; rtargv[rtargc++] = pfile;
63 >                }
64 >                rtargv[rtargc++] = vval(OCTREE);
65 >                rtargv[rtargc] = NULL;
66          }
62        rtargv[rtargc++] = vval(OCTREE);
63        rtargv[rtargc] = NULL;
67          maxqlen = 0;
68 <        for (nprocs = 0; nprocs < npt; nprocs++) {      /* spawn children */
68 >        for (nprocs = 0; nprocs < ncprocs; nprocs++) {  /* spawn children */
69                  psiz = open_process(rtpd[nprocs], rtargv);
70                  if (psiz <= 0)
71                          error(SYSTEM, "cannot start rtrace process");
# Line 71 | Line 74 | start_rtrace()                 /* start rtrace process */
74                          if (!(maxqlen = n))
75                                  error(INTERNAL,
76                                          "bad pipe buffer size assumption");
77 +                        sleep(2);
78                  } else if (n != maxqlen)
79                          error(INTERNAL, "varying pipe buffer size!");
80                  rmaxpack += n;
# Line 291 | Line 295 | killpersist()                  /* kill persistent process */
295          FILE    *fp;
296          int     pid;
297  
298 <        if ((fp = fopen(PFILE, "r")) == NULL)
298 >        if ((fp = fopen(pfile, "r")) == NULL)
299                  return;
300          if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0)
301 <                unlink(PFILE);
301 >                unlink(pfile);
302          fclose(fp);
303   }
304  
# Line 311 | Line 315 | end_rtrace()                   /* close rtrace process(es) */
315                  if (rv > 0)
316                          status = rv;
317          }
318 <        free((char *)rtbuf);
318 >        free((void *)rtbuf);
319          rtbuf = NULL;
320          maxqlen = 0;
321          return(status);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines