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

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.66 by greg, Thu Sep 9 00:25:59 2004 UTC vs.
Revision 3.78 by greg, Mon Mar 21 19:06:08 2016 UTC

# Line 21 | Line 21 | static const char      RCSid[] = "$Id$";
21   #define FRAGWARN        20              /* fragmentation for warning (%) */
22   #endif
23   #ifndef MAXQTIME
24 < #define MAXQTIME        5               /* target maximum seconds in queue */
24 > #define MAXQTIME        3               /* target maximum seconds in queue */
25   #endif
26                                          /* manual cache flushing frequency */
27   #ifndef RTFLUSH
# Line 55 | Line 55 | time_t reporttime;             /* time for next report */
55   off_t   maxdisk;                /* maximum file space (bytes) */
56  
57   int     rtargc = 1;             /* rtrace command */
58 < char    *rtargv[128] = {"rtrace", NULL};
58 > char    *rtargv[MAXRTARGC] = {"rtrace", NULL};
59  
60   int     orig_mode = -1;         /* original file mode (-1 if unchanged) */
61  
# Line 90 | Line 90 | main(
90   {
91          int     i;
92  
93        initurand(16384);                       /* initialize urand */
93          progname = argv[0];                     /* get arguments */
94          for (i = 1; i < argc && argv[i][0] == '-'; i++)
95                  switch (argv[i][1]) {
# Line 165 | Line 164 | main(
164          quit(0);
165   userr:
166          fprintf(stderr,
167 < "Usage: %s [-n nprocs][-o disp][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
167 > "Usage: %s [-n nprocs][-o disp][-i][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
168                          progname);
169          quit(1);
170          return 1; /* pro forma return */
# Line 185 | Line 184 | onsig(                         /* fatal signal */
184                  hdsync(NULL, 0);        /* don't leave w/o saying goodbye */
185                  _exit(signo);
186          }
187 <        alarm(300);                     /* allow 5 minutes to clean up */
187 >        alarm(300);                     /* allow 10 minutes to clean up */
188          eputs("signal - ");
189          eputs(sigerr[signo]);
190          eputs("\n");
# Line 320 | Line 319 | memerr:
319   static int
320   rholo(void)                             /* holodeck main loop */
321   {
322 <        static long     nextfragwarn = 100*(1L<<20);
322 >        static off_t    nextfragwarn = 100L<<20;
323          static int      idle = 0;
324          PACKET  *pl = NULL, *plend;
325          off_t   fsiz;
# Line 339 | Line 338 | rholo(void)                            /* holodeck main loop */
338                  return(0);              /* all done */
339          fsiz = hdfilen(hdlist[0]->fd);  /* check file size */
340          if (maxdisk > 0 && fsiz >= maxdisk) {
341 <                error(WARNING, "file limit exceeded");
341 >                error(USER, "file limit exceeded");
342                  done_rtrace();
343                  return(1);      /* comes back */
344          }
345   #if FRAGWARN
346 <        if (fsiz >= nextfragwarn &&
347 <                    (fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) {
348 <                double  pctfrag = 100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz;
350 <                if (pctfrag >= (double)FRAGWARN) {
346 >        if (fsiz >= nextfragwarn) {
347 >                double  pctfrag = 100.*(fsiz-hdfiluse(hdlist[0]->fd))/fsiz;
348 >                if (pctfrag >= (double)FRAGWARN) {
349                          sprintf(errmsg, "holodeck file fragmentation is %.0f%%",
350                                          pctfrag);
351                          error(WARNING, errmsg);
352                          nextfragwarn = fsiz + (fsiz>>2);
353 <                }
353 >                } else
354 >                        nextfragwarn = fsiz + (10L<<20);
355          }
356   #endif
357          t = time(NULL);                 /* check time */
358          if (endtime > 0 && t >= endtime) {
359 <                error(WARNING, "time limit exceeded");
359 >                error(USER, "time limit exceeded");
360                  done_rtrace();
361                  return(1);      /* comes back */
362          }
# Line 416 | Line 415 | setdefaults(                   /* set default values */
415          }
416                                  /* append rendering options */
417          if (vdef(RENDER))
418 <                rtargc += wordstring(rtargv+rtargc, vval(RENDER));
418 >                rtargc += wordstring(rtargv+rtargc, MAXRTARGC-rtargc, vval(RENDER));
419          
420          if (gp == NULL)         /* already initialized? */
421                  return;
# Line 454 | Line 453 | creatholo(                     /* create a holodeck output file */
453   )
454   {
455          extern char     VersionID[];
456 <        int32   lastloc, nextloc;
456 >        off_t   lastloc, nextloc;
457          int     n;
458          int     fd;
459          FILE    *fp;
# Line 480 | Line 479 | creatholo(                     /* create a holodeck output file */
479                  if (!n)
480                          break;
481                  nextloc = hdfilen(fd);          /* write section pointer */
482 <                if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0)
482 >                if (lseek(fd, lastloc, SEEK_SET) < 0)
483                          error(SYSTEM,
484                                  "cannot seek on holodeck file in creatholo");
485                  write(fd, (char *)&nextloc, sizeof(nextloc));
486 <                lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET);
486 >                lseek(fd, (lastloc=nextloc), SEEK_SET);
487          }
488   }
489  
# Line 523 | Line 522 | loadholo(void)                 /* start loading a holodeck from fnam
522          FILE    *fp;
523          int     fd;
524          int     n;
525 <        int32   nextloc;
525 >        off_t   nextloc;
526          
527          if ((ncprocs > 0) & (force >= 0))
528                  fp = fopen(hdkfile, "r+");
# Line 535 | Line 534 | loadholo(void)                 /* start loading a holodeck from fnam
534                          error(SYSTEM, errmsg);
535                  }
536                  if (ncprocs > 0) {
537 <                        sprintf(errmsg,
538 <                        "\"%s\" opened read-only; new rays will be discarded",
539 <                                        hdkfile);
537 >                        sprintf(errmsg, "\"%s\" is read-only", hdkfile);
538 >                        if (outdev == NULL)
539 >                                error(USER, errmsg);
540 >                        strcat(errmsg, "; new rays will be discarded");
541                          error(WARNING, errmsg);
542                          force = -1;
543                  }
# Line 554 | Line 554 | loadholo(void)                 /* start loading a holodeck from fnam
554          fd = dup(fileno(fp));
555          fclose(fp);                             /* done with stdio */
556          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
557 <                lseek(fd, (off_t)nextloc, SEEK_SET);
557 >                lseek(fd, nextloc, SEEK_SET);
558                  read(fd, (char *)&nextloc, sizeof(nextloc));
559                  hdinit(fd, NULL);
560          }
# Line 662 | Line 662 | int    ec;
662                  if ((ncprocs > 0) & (force >= 0) && vdef(REPORT)) {
663                          off_t   fsiz, fuse;
664                          fsiz = hdfilen(hdlist[0]->fd);
665 <                        fuse = hdfiluse(hdlist[0]->fd, 1);
665 >                        fuse = hdfiluse(hdlist[0]->fd);
666                          fprintf(stderr,
667                          "%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n",
668                                          hdkfile, fsiz/(1024.*1024.),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines