[Phpfreechat-svn] SF.net SVN: phpfreechat: [1093] trunk/src/containers/file.class.php
Status: Beta
Brought to you by:
kerphi
|
From: <gpi...@us...> - 2007-08-06 23:58:21
|
Revision: 1093
http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1093&view=rev
Author: gpinzone
Date: 2007-08-06 16:58:20 -0700 (Mon, 06 Aug 2007)
Log Message:
-----------
Changed popMeta to act more like a traditional pop command than a drop in replacement for existing algorithm. Cleaned up setMeta.
Modified Paths:
--------------
trunk/src/containers/file.class.php
Modified: trunk/src/containers/file.class.php
===================================================================
--- trunk/src/containers/file.class.php 2007-08-06 19:59:53 UTC (rev 1092)
+++ trunk/src/containers/file.class.php 2007-08-06 23:58:20 UTC (rev 1093)
@@ -248,35 +248,33 @@
{
$ret["value"][] = chop(fread($fh, filesize($leaffilename)));
$ret["timestamp"][] = filemtime($leaffilename);
- $leafvalue = $ret;
- array_pop($leafvalue);
+ $leafvalue = array_pop($ret);
// check if array is now empty
- if (count($leafvalue) == 0)
+ if (count($ret) == 0)
{
+ fclose($fh);
unlink($leaffilename);
break;
}
rewind($fh);
- fwrite($fh, $leafvalue);
+ fwrite($fh, $ret);
fflush($fh);
ftruncate($fh, ftell($fh));
flock($fh, LOCK_UN);
+ fclose($fh);
break;
}
// If flock is working properly, this will never be reached
$delay = rand(0, pow(2, ($i+1)) - 1) * 5000; // Exponential backoff
usleep($delay);
}
- fclose($fh);
+ $ret = $leafvalue;
}
else
{
+ // return empty array
return $ret;
}
-
- $ret["value"][] = $leafvalue;
- $ret["timestamp"][] = filemtime($leaffilename);
-
return $ret;
}
@@ -295,11 +293,6 @@
// create or replace metadata file
$leaffilename = $dir."/".$leaf;
- // create return array
- $ret = array();
- $ret["timestamp"] = array();
- $ret["value"] = array();
-
// read and increment data from metadata file
clearstatcache();
if ( $leafexists = file_exists($leaffilename) )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|