Says kschwab:
Oh, I see. You are figuring the rename() updates the mtime for the file.
No, I'm not. Here is what your loop looked
like before you added the sleep at my suggestion:
while (1) {
$mtime=(stat($data_file . $$))[9];
# drop out of the loop if the file hasn't
# changed in 5 minutes (perhaps longer
# for a wan connection ?)
last if (time > $mtime + 300);
}
Suppose your program executes the rename and then enters
this loop just after the remote process
has finished updating the
file. In that case, the file's mtime is the current
time. You then spend five minutes busy-waiting in
this loop.
Or instead, suppose that the remote process reopens the file for writing
just before you do the rename, and spends
sixty minutes updating the file. Your program will spend
65 minutes busy-waiting in the loop.
|