--- ray/src/hd/rholo.c 2004/09/09 01:06:19 3.67 +++ ray/src/hd/rholo.c 2010/09/30 15:43:30 3.75 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rholo.c,v 3.67 2004/09/09 01:06:19 greg Exp $"; +static const char RCSid[] = "$Id: rholo.c,v 3.75 2010/09/30 15:43:30 greg Exp $"; #endif /* * Radiance holodeck generation controller @@ -21,7 +21,7 @@ static const char RCSid[] = "$Id: rholo.c,v 3.67 2004/ #define FRAGWARN 20 /* fragmentation for warning (%) */ #endif #ifndef MAXQTIME -#define MAXQTIME 5 /* target maximum seconds in queue */ +#define MAXQTIME 3 /* target maximum seconds in queue */ #endif /* manual cache flushing frequency */ #ifndef RTFLUSH @@ -90,7 +90,6 @@ main( { int i; - initurand(16384); /* initialize urand */ progname = argv[0]; /* get arguments */ for (i = 1; i < argc && argv[i][0] == '-'; i++) switch (argv[i][1]) { @@ -165,7 +164,7 @@ main( quit(0); userr: fprintf(stderr, -"Usage: %s [-n nprocs][-o disp][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n", +"Usage: %s [-n nprocs][-o disp][-i][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n", progname); quit(1); return 1; /* pro forma return */ @@ -320,10 +319,10 @@ memerr: static int rholo(void) /* holodeck main loop */ { - static long nextfragwarn = 100*(1L<<20); + static off_t nextfragwarn = 100L<<20; static int idle = 0; PACKET *pl = NULL, *plend; - off_t fsiz, fuse; + off_t fsiz; int pksiz; register PACKET *p; time_t t; @@ -339,22 +338,25 @@ rholo(void) /* holodeck main loop */ return(0); /* all done */ fsiz = hdfilen(hdlist[0]->fd); /* check file size */ if (maxdisk > 0 && fsiz >= maxdisk) { - error(WARNING, "file limit exceeded"); + error(USER, "file limit exceeded"); done_rtrace(); return(1); /* comes back */ } #if FRAGWARN - if (fsiz >= nextfragwarn && - (fsiz-(fuse=hdfiluse(hdlist[0]->fd)))/(fsiz/100) > FRAGWARN) { - sprintf(errmsg, "holodeck file fragmentation is %.0f%%", - 100.*(fsiz-fuse)/fsiz); - error(WARNING, errmsg); - nextfragwarn = fsiz + (fsiz>>2); + if (fsiz >= nextfragwarn) { + double pctfrag = 100.*(fsiz-hdfiluse(hdlist[0]->fd))/fsiz; + if (pctfrag >= (double)FRAGWARN) { + sprintf(errmsg, "holodeck file fragmentation is %.0f%%", + pctfrag); + error(WARNING, errmsg); + nextfragwarn = fsiz + (fsiz>>2); + } else + nextfragwarn = fsiz + (10L<<20); } #endif t = time(NULL); /* check time */ if (endtime > 0 && t >= endtime) { - error(WARNING, "time limit exceeded"); + error(USER, "time limit exceeded"); done_rtrace(); return(1); /* comes back */ } @@ -451,7 +453,7 @@ creatholo( /* create a holodeck output file */ ) { extern char VersionID[]; - int32 lastloc, nextloc; + off_t lastloc, nextloc; int n; int fd; FILE *fp; @@ -477,11 +479,11 @@ creatholo( /* create a holodeck output file */ if (!n) break; nextloc = hdfilen(fd); /* write section pointer */ - if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0) + if (lseek(fd, lastloc, SEEK_SET) < 0) error(SYSTEM, "cannot seek on holodeck file in creatholo"); write(fd, (char *)&nextloc, sizeof(nextloc)); - lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET); + lseek(fd, (lastloc=nextloc), SEEK_SET); } } @@ -520,7 +522,7 @@ loadholo(void) /* start loading a holodeck from fnam FILE *fp; int fd; int n; - int32 nextloc; + off_t nextloc; if ((ncprocs > 0) & (force >= 0)) fp = fopen(hdkfile, "r+"); @@ -532,9 +534,10 @@ loadholo(void) /* start loading a holodeck from fnam error(SYSTEM, errmsg); } if (ncprocs > 0) { - sprintf(errmsg, - "\"%s\" opened read-only; new rays will be discarded", - hdkfile); + sprintf(errmsg, "\"%s\" is read-only", hdkfile); + if (outdev == NULL) + error(USER, errmsg); + strcat(errmsg, "; new rays will be discarded"); error(WARNING, errmsg); force = -1; } @@ -551,7 +554,7 @@ loadholo(void) /* start loading a holodeck from fnam fd = dup(fileno(fp)); fclose(fp); /* done with stdio */ for (n = 0; nextloc > 0L; n++) { /* initialize each section */ - lseek(fd, (off_t)nextloc, SEEK_SET); + lseek(fd, nextloc, SEEK_SET); read(fd, (char *)&nextloc, sizeof(nextloc)); hdinit(fd, NULL); }