A minor inconsistency, don't know if it's documented anywhere... On Windows apr_time_now() and file modification times are the same. So a test program that prints the current time, creates a file and prints its modification time, and then prints the current time again will print something like:
Currently: 1055878859474237 (1055878859.474237) Modified: 1055878859484252 (1055878859.484252) Currently: 1055878859484252 (1055878859.484252) On Linux (at least Mandrake 9.0) the file modification time doesn't have the same accuracy. The same program will print something like this: Currently: 1055878859474237 (1055878859.474237) Modified: 1055878859000000 (1055878859.000000) Currently: 1055878859484252 (1055878859.484252) I noticed this when writing some code that was checking modification timestamps to see if files required reloading. The fact that the file modification timestamp dropped the microseconds meant at the file load times I was storing could be later than the file modification time even when the file was modified later than it was loaded. Admittedly this mostly happened during my test program, which was a fairly non-ordinary exercise of the code...but it could occasionally happen during real use. The solution is simple: use apr_time_sec() to drop the microseconds before comparing the two (and treat equal values as requiring update). I don't remember reading this in any of the APR documentation, however. I would like to put a note in the file_stat module pointing this out, and I'm including a patch from the httpd-2.1 tree, file apr_file_info.h, to do so. This is merely a documentation change, no code is involved: Index: apr_file_info.h =================================================================== RCS file: /home/cvspublic/apr/include/apr_file_info.h,v retrieving revision 1.40 diff -r1.40 apr_file_info.h 166a167,180 > > /** > * @warning > * File system timestamps are not stored with the same accuracy on all > * platforms. For example, on Windows 2000 they are stored to the > * microsecond whereas on Mandrake Linux 9.0 they are stored to the second. > * Code that compares the result of apr_time_now() (e.g. a 'file loaded' > * timestamp) to apr_finfo_t.mtime may only work on some platforms in > * extreme cases, such as when a file is modified within a second of its > * load time but the stored modification timestamp is actually earlier > * than the previous file loaded timetamp. If this is an issue, use > * apr_time_sec() on both operands when comparing times. > */ > mma