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

Comparing ray/src/hd/holofile.c (file contents):
Revision 3.12 by gregl, Fri Dec 12 19:52:31 1997 UTC vs.
Revision 3.13 by gregl, Fri Dec 12 21:29:34 1997 UTC

# Line 38 | Line 38 | HOLO   *hdlist[HDMAX+1];       /* holodeck pointers (NULL term
38  
39   static struct fragment {
40          short   nlinks;         /* number of holodeck sections using us */
41 <        short   nfrags;         /* number of known fragments */
41 >        short   writerr;        /* write error encountered */
42 >        int     nfrags;         /* number of known fragments */
43          BEAMI   *fi;            /* fragments, descending file position */
44          long    flen;           /* last known file length */
45   } *hdfrag;              /* fragment lists, indexed by file descriptor */
# Line 138 | Line 139 | HDGRID *hproto;                /* holodeck section grid */
139          hp->fd = fd;    
140          hp->dirty = 0;
141          biglob(hp)->fo = fpos + sizeof(HDGRID);
142 <        biglob(hp)->nrd = 0;            /* count rays on disk */
143 <        for (n = nbeams(hp); n > 0; n--)
144 <                biglob(hp)->nrd += hp->bi[n].nrd;
142 >                                        /* start tracking fragments */
143 >        hdattach(fd);
144 >                                        /* check rays on disk */
145 >        fpos = hdfilen(fd);
146 >        biglob(hp)->nrd = 0;
147 >        for (n = hproto == NULL ? nbeams(hp) : 0; n > 0; n--)
148 >                if (hp->bi[n].nrd)
149 >                        if (hp->bi[n].fo + hp->bi[n].nrd > fpos)
150 >                                hp->bi[n].nrd = 0;      /* off end */
151 >                        else
152 >                                biglob(hp)->nrd += hp->bi[n].nrd;
153                                          /* add to holodeck list */
154          for (n = 0; n < HDMAX; n++)
155                  if (hdlist[n] == NULL) {
156                          hdlist[n] = hp;
157                          break;
158                  }
150                                        /* start tracking fragments (last) */
151        hdattach(fd);
159                                          /* all done */
160          return(hp);
161   memerr:
# Line 173 | Line 180 | int    all;
180          for (j = all ? nbeams(hp) : 0; j > 0; j--)
181                  if (hp->bl[j] != NULL)
182                          hdsyncbeam(hp, j);
183 <        if (!hp->dirty)                 /* directory dirty? */
183 >        if (!hp->dirty)                 /* directory clean? */
184                  return(0);
185          errno = 0;
186          if (lseek(hp->fd, biglob(hp)->fo, 0) < 0)
# Line 347 | Line 354 | register int   i;
354          unsigned int    nrays;
355          long    nfo;
356          unsigned int    n;
357 +                                        /* check file status */
358 +        if (hdfrag[hp->fd].writerr)
359 +                return(-1);
360   #ifdef DEBUG
361          if (i < 1 | i > nbeams(hp))
362                  error(CONSISTENCY, "bad beam index in hdsyncbeam");
# Line 354 | Line 364 | register int   i;
364                                          /* is current fragment OK? */
365          if (hp->bl[i] == NULL || (nrays = hp->bl[i]->nrm) == hp->bi[i].nrd)
366                  return(0);
367 <                                        /* check file status */
358 <        if (hp->dirty < 0)
359 <                return(-1);
360 <
367 >                                        /* locate fragment */
368          if (hp->fd >= nhdfrags || !hdfrag[hp->fd].nlinks) /* untracked */
369                  hp->bi[i].fo = lseek(hp->fd, 0L, 2);
370  
# Line 435 | Line 442 | register int   i;
442                          error(SYSTEM, "cannot seek on holodeck file");
443                  n = hp->bl[i]->nrm * sizeof(RAYVAL);
444                  if (write(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) {
445 <                        hp->dirty = -1;         /* avoid recursive error */
445 >                        hdfrag[hp->fd].writerr++;
446 >                        hdsync(hp, 0);          /* sync directory */
447                          error(SYSTEM, "write error in hdsyncbeam");
448                  }
449          }
# Line 460 | Line 468 | register int   i;
468                          nchanged += hdfreebeam(hdlist[i], 0);
469                  return(nchanged);
470          }
471 +        if (hdfrag[hp->fd].writerr)     /* check for file error */
472 +                return(0);
473          if (i == 0) {                   /* clear entire holodeck */
474                  nchanged = 0;
475                  for (i = nbeams(hp); i > 0; i--)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines