--- MemCachedClient.inc.php1 2003-07-27 22:18:14.000000000 +0100
+++ MemCachedClient.inc.php 2003-07-28 09:15:36.000000000 +0100
@@ -76,7 +76,7 @@
$sock = $this->get_sock($key);
- if(!$sock)
+ if(! is_resource($sock))
return 0;
if(is_array($key))
@@ -134,6 +134,8 @@
// like get() but takes an array of keys
function get_multi($keys)
{
+ $socks = array();
+
if(!$this->active)
return null;
@@ -147,7 +149,7 @@
{
$sock = $this->get_sock($k);
- if($sock)
+ if(is_resource($sock))
{
$k = is_array($k) ? $k[1] : $k;
@@ -267,7 +269,7 @@
$host = $this->buckets[$hv % $this->bucketcount];
$sock = $this->sock_to_host($host);
- if($sock)
+ if(is_resource($sock))
return $sock;
$hv += $this->_hashfunc($tries);
@@ -284,7 +286,7 @@
return 0;
$sock = $this->get_sock($key);
- if(!$sock)
+ if(!is_resource($sock))
return 0;
$flags = 0;
@@ -298,9 +300,12 @@
}
$len = strlen($val);
+ if (!is_int($exptime))
+ $exptime = 0;
// send off the request
$cmd = "$cmdname $key $flags $exptime $len\r\n$val\r\n";
+# echo "
Command is: $cmd
\n";
$cmd_len = strlen($cmd);
$offset = 0;
@@ -308,7 +313,9 @@
$offset += socket_write($sock, substr($cmd, $offset, MC_BUFFER_SZ), MC_BUFFER_SZ);
// now read the server's response
- if(socket_read($sock, 6, PHP_NORMAL_READ) == "STORED")
+ $l_szResponse = socket_read($sock, 30, PHP_NORMAL_READ);
+# echo $l_szResponse . "
\n";
+ if($l_szResponse == "STORED")
{
if($this->debug)
print "MemCache: $cmdname $key = $raw_val\n";
@@ -318,7 +325,7 @@
else
{
if($this->debug)
- print "_set(): Did not receive STORED as the server response!\r\n";
+ print "_set(): Did not receive STORED as the server response!\r\n; received $l_szResponse instead";
}
return 0;
@@ -344,6 +351,7 @@
$cmd .="\r\n";
$cmd_len = strlen($cmd);
+
$offset = 0;
while($offset < $cmd_len)