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.12 by greg, Sat Feb 22 02:07:25 2003 UTC vs.
Revision 3.13 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Routines for local rtrace execution
6   */
7  
8 + #include <signal.h>
9 + #include <sys/time.h>
10 +
11   #include "rholo.h"
12   #include "random.h"
13   #include "paths.h"
14   #include "selcall.h"
15 < #include <signal.h>
13 < #include <sys/time.h>
15 > #include "rtprocess.h"
16  
17   #ifndef MAXPROC
18   #define MAXPROC         64
# Line 20 | Line 22 | int    nprocs = 0;                             /* running process count */
22  
23   static char     pfile[] = TEMPLATE;             /* persist file name */
24  
25 < static int      rtpd[MAXPROC][3];               /* process descriptors */
25 > static SUBPROC  rtpd[MAXPROC];          /* process descriptors */
26   static float    *rtbuf = NULL;                  /* allocated i/o buffer */
27   static int      maxqlen = 0;                    /* maximum packets per queue */
28  
# Line 66 | Line 68 | start_rtrace()                 /* start rtrace process */
68          }
69          maxqlen = 0;
70          for (nprocs = 0; nprocs < ncprocs; nprocs++) {  /* spawn children */
71 <                psiz = open_process(rtpd[nprocs], rtargv);
71 >                psiz = open_process(&rtpd[nprocs], rtargv);
72                  if (psiz <= 0)
73                          error(SYSTEM, "cannot start rtrace process");
74                  n = psiz/(RPACKSIZ*6*sizeof(float));
# Line 135 | Line 137 | register PACKET        *p;
137          packrays(rtbuf, p);
138          if ((n = p->nr) < RPACKSIZ)     /* add flush block? */
139                  bzero((char *)(rtbuf+6*n++), 6*sizeof(float));
140 <        if (writebuf(rtpd[pn][1], (char *)rtbuf, 6*sizeof(float)*n) < 0)
140 >        if (writebuf(rtpd[pn].w, (char *)rtbuf, 6*sizeof(float)*n) < 0)
141                  error(SYSTEM, "write error in queue_packet");
142          p->next = NULL;
143          if (!pqlen[pn]++)       /* add it to the end of the queue */
# Line 164 | Line 166 | int    poll;
166          FD_ZERO(&readset); FD_ZERO(&errset); n = 0;
167          for (pn = nprocs; pn--; ) {
168                  if (pqlen[pn])
169 <                        FD_SET(rtpd[pn][0], &readset);
170 <                FD_SET(rtpd[pn][0], &errset);
171 <                if (rtpd[pn][0] >= n)
172 <                        n = rtpd[pn][0] + 1;
169 >                        FD_SET(rtpd[pn].r, &readset);
170 >                FD_SET(rtpd[pn].r, &errset);
171 >                if (rtpd[pn].r >= n)
172 >                        n = rtpd[pn].r + 1;
173          }
174                                          /* make the call */
175          n = select(n, &readset, (fd_set *)NULL, &errset,
# Line 181 | Line 183 | int    poll;
183                  return(NULL);
184                                          /* make read call(s) */
185          for (pn = 0; pn < nprocs; pn++) {
186 <                if (!FD_ISSET(rtpd[pn][0], &readset) &&
187 <                                !FD_ISSET(rtpd[pn][0], &errset))
186 >                if (!FD_ISSET(rtpd[pn].r, &readset) &&
187 >                                !FD_ISSET(rtpd[pn].r, &errset))
188                          continue;
189          reread:
190 <                n = read(rtpd[pn][0], (char *)rtbuf,
190 >                n = read(rtpd[pn].r, (char *)rtbuf,
191                                  4*sizeof(float)*RPACKSIZ*pqlen[pn]);
192                  if (n < 0) {
193                          if (errno == EINTR | errno == EAGAIN)
# Line 200 | Line 202 | int    poll;
202                                  nr++;                   /* add flush block */
203                          n -= 4*sizeof(float)*nr;
204                          if (n < 0) {                    /* get remainder */
205 <                                n += readbuf(rtpd[pn][0],
205 >                                n += readbuf(rtpd[pn].r,
206                                                  (char *)(bp+4*nr)+n, -n);
207                                  if (n)
208                                          goto eoferr;
# Line 267 | Line 269 | flush_queue()                  /* empty all rtrace queues */
269                                  if (rpl->nr < RPACKSIZ)
270                                          nr++;           /* add flush block */
271                          }
272 <                        n = readbuf(rtpd[i][0], (char *)rtbuf,
272 >                        n = readbuf(rtpd[i].r, (char *)rtbuf,
273                                          4*sizeof(float)*nr);
274                          if (n < 0)
275                                  error(SYSTEM, "read failure in flush_queue");
# Line 311 | Line 313 | end_rtrace()                   /* close rtrace process(es) */
313          if (nprocs > 1)
314                  killpersist();
315          while (nprocs > 0) {
316 <                rv = close_process(rtpd[--nprocs]);
316 >                rv = close_process(&rtpd[--nprocs]);
317                  if (rv > 0)
318                          status = rv;
319          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines