--- ray/src/common/readoct.c 2019/05/04 00:32:47 2.31 +++ ray/src/common/readoct.c 2023/06/08 17:39:13 2.33 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: readoct.c,v 2.31 2019/05/04 00:32:47 greg Exp $"; +static const char RCSid[] = "$Id: readoct.c,v 2.33 2023/06/08 17:39:13 greg Exp $"; #endif /* * readoct.c - routines to read octree information. @@ -41,6 +41,8 @@ readoct( /* read in octree file or stream */ char *ofn[] ) { + time_t oct_t = 0; + time_t last_it = 0; char sbuf[512]; int nf; int i; @@ -62,7 +64,11 @@ readoct( /* read in octree file or stream */ inpspec); error(SYSTEM, errmsg); } + oct_t = fddate(fileno(infp)); } +#ifdef getc_unlocked /* avoid stupid semaphores */ + flockfile(infp); +#endif SET_FILE_BINARY(infp); /* get header */ if (checkheader(infp, OCTFMT, load&IO_INFO ? stdout : (FILE *)NULL) < 0) @@ -87,6 +93,11 @@ readoct( /* read in octree file or stream */ readobj(sbuf); if (load & IO_FILES) ofn[nf] = savqstr(sbuf); + if (oct_t > last_it) { + time_t t = fdate(sbuf); + if (t > last_it) + last_it = t; + } nf++; } if (load & IO_FILES) @@ -111,7 +122,7 @@ readoct( /* read in octree file or stream */ if (nobjects != objorig+fnobjects) octerror(USER, "bad object count; octree stale?"); /* check for non-surfaces */ - if (nonsurfintree(scene->cutree)) + if (oct_t <= last_it && nonsurfintree(scene->cutree)) octerror(USER, "modifier in tree; octree stale?"); } } @@ -120,6 +131,10 @@ readoct( /* read in octree file or stream */ pclose(infp); else if (infp != stdin) fclose(infp); +#ifdef getc_unlocked + else + funlockfile(infp); +#endif return(nf); }