Tim Bray
Thu, 02 Oct 2008 23:41:04 -0700
status = apr_file_open(&fp, tempname, APR_FOPEN_WRITE | APR_FOPEN_CREATE,
PERMS, pool);
/* ... do lots of writing ... */
apr_file_flush(fp);
apr_file_close(fp);
status = apr_file_rename(tempname, filename, pool); /* filename
is in the same directory as tempname */
BOOM! strerror() says "no such file or directory"
Then if I go and look, what do you know, the tempfile actually is
there. If I process 500 requests in a big hurry, 100 each from 5
concurrent clients, this will happen maybe half a dozen times, in an
unpredictable order. There are ways to work around this, but still,
it's kinda disturbing. It's either, in decreasing order of
probability (a) me doing something stupid, (b) OS X filesystem
weirdness, (c) an APR bug. apr_file_write_full() doesn't seem to make
a difference.
Same code running in -X single-threaded mode, no problem. Same code on Solaris, no problem. (Well, yes, there are other weird Solaris problems with mutexes, but we'll get to those).
-T