From: Tim Starling Date: Sat, 25 Sep 2004 16:50:27 +0000 (+0000) Subject: More debugging info, better hashing function - crc32() goes negative in live PHP! X-Git-Tag: 1.5.0alpha1~1795 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=8089d9774f9090def92e8c68c8f7af3cb6f49098;p=lhc%2Fweb%2Fwiklou.git More debugging info, better hashing function - crc32() goes negative in live PHP! --- diff --git a/includes/memcached-client.php b/includes/memcached-client.php index 48f10090ab..bed0ebf63d 100644 --- a/includes/memcached-client.php +++ b/includes/memcached-client.php @@ -649,8 +649,11 @@ class memcached $sock = @fsockopen($ip, $port, $errno, $errstr, $timeout); } - if (!$sock) + if (!$sock) { + if ($this->_debug) + $this->_debugprint( "Error connecting to $host: $errstr\n" ); return false; + } return true; } @@ -737,7 +740,10 @@ class memcached */ function _hashfunc ($key) { - return crc32($key); + # Hash function must on [0,0x7ffffff] + # We take the first 31 bits of the MD5 hash, which unlike the hash + # function used in a previous version of this client, works + return hexdec(substr(md5($key),0,8)) & 0x7fffffff; } // }}}