From deb1066e17fd8815197bb77b39cc78051ed8f79d Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 3 Dec 2003 13:08:11 +0000 Subject: [PATCH] Memcached client bug fix (submitted to memcached mailing list) --- includes/MemCachedClient.inc.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/MemCachedClient.inc.php b/includes/MemCachedClient.inc.php index a737e5dc82..6bee4fdfa0 100644 --- a/includes/MemCachedClient.inc.php +++ b/includes/MemCachedClient.inc.php @@ -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 +?> -- 2.20.1