Memcached client bug fix (submitted to memcached mailing list)
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 3 Dec 2003 13:08:11 +0000 (13:08 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 3 Dec 2003 13:08:11 +0000 (13:08 +0000)
includes/MemCachedClient.inc.php

index a737e5d..6bee4fd 100644 (file)
@@ -1060,6 +1060,16 @@ class MemCachedClient
                        $bytes_read += strlen($line);
                        $buf .= $line;
 
+                       // if we're almost at the end, read the rest, so 
+                       // that we don't corrupt the \r\nEND\r\n
+                       if ($bytes_read >= $len)
+                       {
+                               $lastbit = socket_read($sock, $len - $bytes_read + 7, PHP_BINARY_READ);
+                               $line .= $lastbit;
+                               $buf .= $lastbit;
+                               $bytes_read += strlen($lastbit);
+                       }
+
                        // we read the all of the data, take in account
                        // for the /r/nEND/r/n
                        if($bytes_read == ($len + 7))
@@ -1140,4 +1150,4 @@ class MemCachedClient
     }
 }
 
-?>
\ No newline at end of file
+?>