summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2011-09-29 17:16:11 +0000
committerUrban Müller2011-09-29 17:16:11 +0000
commit8c2af30bee2335786f13f5420e4e42f7fcdfcbc9 (patch)
tree1a5c95818c710fbf7015cf1c3dc4e8688b3bbb51
parent6f20e84eec00c5a66c12dba9c102f67293a8cdcb (diff)
downloaditools-8c2af30bee2335786f13f5420e4e42f7fcdfcbc9.tar.gz
itools-8c2af30bee2335786f13f5420e4e42f7fcdfcbc9.tar.bz2
itools-8c2af30bee2335786f13f5420e4e42f7fcdfcbc9.zip
fix race
-rw-r--r--it.class11
1 files changed, 6 insertions, 5 deletions
diff --git a/it.class b/it.class
index b01285e..8d751a0 100644
--- a/it.class
+++ b/it.class
@@ -84,15 +84,16 @@ static function log($name /* ... */)
if (substr($fullfn, 0, 1) == "/")
{
- $existed = file_exists($fullfn);
- file_put_contents($fullfn, $line, FILE_APPEND);
-
- if (!$existed)
+ if (!file_exists($fullfn))
{
- @chgrp($fullfn, "www");
+ @touch("$fullfn.tmp");
+ @chgrp("$fullfn.tmp", "www");
+ @rename("$fullfn.tmp", $fullfn);
@unlink($basefn);
@symlink($fullfn, $basefn);
}
+
+ file_put_contents($fullfn, $line, FILE_APPEND);
}
}