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

Comparing ray/src/rt/persist.c (file contents):
Revision 2.27 by greg, Tue Feb 25 02:47:23 2003 UTC vs.
Revision 2.32 by greg, Mon Oct 20 16:01:55 2003 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9  
10   #include "copyright.h"
11  
12 + #include <string.h>
13 + #include <signal.h>
14 + #include <sys/stat.h>
15 +
16 + #include "rtprocess.h" /* getpid() */
17   #include "standard.h"
18 + #include "platform.h"
19   #include "random.h"
20  
21   #ifdef F_SETLKW
22   #include "paths.h"
23   #include "selcall.h"
18 #include <signal.h>
19 #include <sys/stat.h>
24  
25   #ifndef TIMELIM
26   #define TIMELIM         (8*3600)        /* time limit for holding pattern */
27   #endif
28  
25 #ifndef freebsd
26 #define mkfifo(fn,md)   mknod(fn, S_IFIFO|(md), 0)
27 #endif
28
29   extern void     io_process();
30  
31   extern int      headismine;     /* boolean true if header belongs to me */
# Line 85 | Line 85 | int    lf;
85   }
86  
87  
88 + void
89   persistfile(pfn)        /* open persist file and lock it */
90   char    *pfn;
91   {
# Line 136 | Line 137 | pfhold()               /* holding pattern for idle rendering proces
137          n = strlen(buf);
138          if (write(persistfd, buf, n) < n)
139                  error(SYSTEM, "error writing persist file");
140 <        lseek(persistfd, (off_t)0L, 0);
140 >        lseek(persistfd, (off_t)0, SEEK_SET);
141                                  /* wait TIMELIM for someone to signal us */
142          got_io = 0;
143          signal(SIGIO, sig_io);
# Line 204 | Line 205 | io_process()           /* just act as go-between for actual pro
205          }
206          if (nr < 0)
207                  error(SYSTEM, "error reading persist file");
208 + #ifndef _WIN32 /* XXX we need a replacement for that one */
209          ftruncate(persistfd, (off_t)0L);        /* truncate persist file */
210 + #endif
211          pfdetach();                     /* close & release persist file */
212          buf[nr] = '\0';                 /* parse what we got */
213 <        if ((cp = index(buf, ' ')) == NULL)
213 >        if ((cp = strchr(buf, ' ')) == NULL)
214                  goto formerr;
215          *cp++ = '\0';
216          if ((pid = atoi(cp)) <= 0)
217                  goto formerr;
218 <        if ((cp = index(cp, '\n')) == NULL)
218 >        if ((cp = strchr(cp, '\n')) == NULL)
219                  goto formerr;
220          pfin = ++cp;
221 <        if ((cp = index(cp, '\n')) == NULL)
221 >        if ((cp = strchr(cp, '\n')) == NULL)
222                  goto formerr;
223          *cp++ = '\0';
224          pfout = cp;
225 <        if ((cp = index(cp, '\n')) == NULL)
225 >        if ((cp = strchr(cp, '\n')) == NULL)
226                  goto formerr;
227          *cp++ = '\0';
228          pferr = cp;
229 <        if ((cp = index(cp, '\n')) == NULL)
229 >        if ((cp = strchr(cp, '\n')) == NULL)
230                  goto formerr;
231          *cp++ = '\0';
232          if (cp-buf != nr)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines