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

Comparing ray/src/util/rpiece.c (file contents):
Revision 2.11 by greg, Sun Aug 9 23:05:17 1992 UTC vs.
Revision 2.14 by greg, Wed Dec 2 17:07:00 1992 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include "view.h"
16   #include "resolu.h"
17  
18 + #ifndef NFS
19 + #define  NFS                    1
20 + #endif
21                                  /* set the following to 0 to forgo forking */
22   #ifndef MAXFORK
23 + #if NFS
24   #define  MAXFORK                3       /* allotment of duped processes */
25 + #else
26 + #define  MAXFORK                0
27   #endif
28 + #endif
29  
30                                  /* rpict command */
31   char  *rpargv[128] = {"rpict", "-S", "1", "-x", "512", "-y", "512", "-pa", "1"};
# Line 102 | Line 109 | char  *argv[];
109                          case 'F':               /* syncronization file */
110                                  if (argv[i][2])
111                                          break;
112 <                                if ((syncfd = open(argv[++i], O_RDWR)) < 0) {
112 >                                if ((syncfd = open(argv[++i],
113 >                                                O_RDWR|O_CREAT, 0666)) < 0) {
114                                          fprintf(stderr, "%s: cannot open\n",
115                                                          argv[i]);
116                                          exit(1);
# Line 164 | Line 172 | char  **av;
172          } else if ((outfd = open(outfile, O_RDWR)) >= 0) {
173                  if ((fp = fdopen(dup(outfd), "r+")) == NULL)
174                          goto filerr;
175 <                getheader(fp, NULL);            /* skip header */
175 >                getheader(fp, NULL, NULL);      /* skip header */
176                  if (fscnresolu(&hr, &vr, fp) < 0 ||     /* check resolution */
177                                  hr != hres*hmult || vr != vres*vmult) {
178                          fprintf(stderr, "%s: resolution mismatch on file \"%s\"\n",
# Line 179 | Line 187 | char  **av;
187          scanorig = ftell(fp);           /* record position of first scanline */
188          if (fclose(fp) == -1)           /* done with stream i/o */
189                  goto filerr;
190 + #if NFS
191          sync();                         /* flush NFS buffers */
192 + #endif
193                                          /* start rpict process */
194          if (open_process(rpd, rpargv) <= 0) {
195                  fprintf(stderr, "%s: cannot start %s\n", progname, rpargv[0]);
# Line 325 | Line 335 | int  xpos, ypos;
335                  exit(cleanup(1));
336          }
337                                  /* check header from rpict */
338 <        getheader(fromrp, NULL);
338 >        getheader(fromrp, NULL, NULL);
339          if (fscnresolu(&hr, &vr, fromrp) < 0 || hr != hres | vr != vres) {
340                  fprintf(stderr, "%s: resolution mismatch from %s\n",
341                                  progname, rpargv[0]);
# Line 352 | Line 362 | int  xpos, ypos;
362   #else
363          pid = -1;               /* no forking */
364   #endif
365 + #if NFS
366                                  /* lock file section so NFS doesn't mess up */
367          fls.l_whence = 0;
368          fls.l_len = (long)vres*hmult*hres*sizeof(COLR);
369          fls.l_start = scanorig + (vmult-1-ypos)*fls.l_len;
370          fls.l_type = F_WRLCK;
371          fcntl(outfd, F_SETLKW, &fls);
372 + #endif
373                                  /* write new piece to file */
374          if (lseek(outfd, fls.l_start+(long)xpos*hres*sizeof(COLR), 0) == -1)
375                  goto seekerr;
# Line 376 | Line 388 | int  xpos, ypos;
388                                  goto seekerr;
389                  }
390          if (pid == -1) {        /* fork failed */
391 + #if NFS
392                  fls.l_type = F_UNLCK;           /* release lock */
393                  fcntl(outfd, F_SETLKW, &fls);
394 + #endif
395                  return(0);
396          }
397          _exit(0);               /* else exit child process (releasing lock) */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines