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.14 by greg, Sat Jul 6 22:30:05 1996 UTC vs.
Revision 2.15 by greg, Sat Jul 6 23:19:57 1996 UTC

# Line 83 | Line 83 | char   *pfn;
83          persistfd = open(pfn, O_WRONLY|O_CREAT|O_EXCL, 0644);
84          if (persistfd >= 0) {
85                  persistfname = pfn;
86                        /* put something there for faulty lock daemons */
87                write(persistfd, "Initializing...\n", 16);
86                  pflock(1);
87                  return;
88          }
# Line 124 | Line 122 | pfhold()               /* holding pattern for idle rendering proces
122                  goto createrr;
123          sprintf(buf, "%s %d\n%s\n%s\n%s\n", progname, getpid(),
124                          inpname, outpname, errname);
127        if (lseek(persistfd, 0L, 0) < 0)
128                error(SYSTEM, "seek error on persist file");
125          n = strlen(buf);
126          if (write(persistfd, buf, n) < n)
127                  error(SYSTEM, "error writing persist file");
132        ftruncate(persistfd, (long)n);
133        fsync(persistfd);       /* shouldn't be necessary, but.... */
128                                  /* wait TIMELIM for someone to signal us */
129          got_io = 0;
130          signal(SIGIO, sig_io);
131          oldalrm = (int (*)())signal(SIGALRM, sig_alrm);
132          alarm(TIMELIM);
133 <        pflock(0);
133 >        pflock(0);                      /* unlock persist file for attach */
134          while (!got_io)
135 <                pause();
136 <        alarm(0);
135 >                pause();                /* wait for attach */
136 >        pflock(1);                      /* grab persist file right back! */
137 >        alarm(0);                       /* turn off alarm */
138          signal(SIGALRM, oldalrm);
139          signal(SIGIO, SIG_DFL);
140 <        pflock(1);
140 >        if (lseek(persistfd, 0L, 0) < 0 || ftruncate(persistfd, 0L) < 0)
141 >                error(SYSTEM, "seek/truncate error on persist file");
142                                  /* someone wants us; reopen stdin and stdout */
143          if (freopen(inpname, "r", stdin) == NULL)
144                  goto openerr;
# Line 172 | Line 168 | io_process()           /* just act as conduits to and from actu
168          register int    nr, n;
169          char    buf[512], *pfin, *pfout, *pferr;
170          int     pid, pid2 = -1;
171 <                                /* load and close persist file */
172 <        errno = 0;
173 <        nr = read(persistfd, buf, sizeof(buf)-1);
174 <        pfdetach();
175 <        if (nr <= 0)
171 >                                        /* load persist file */
172 >        while ((nr = read(persistfd, buf, sizeof(buf)-1)) == 0) {
173 >                pflock(0);
174 >                sleep(15);              /* wait until ready */
175 >                pflock(1);
176 >        }
177 >        pfdetach();                     /* close persist file */
178 >        if (nr < 0)
179                  error(SYSTEM, "error reading persist file");
180          buf[nr] = '\0';
181          if ((cp = index(buf, ' ')) == NULL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines