r41326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41325‎ | r41326 | r41327 >
Date:23:36, 27 September 2008
Author:aaron
Status:old
Tags:
Comment:
Avoid strange negative bucket key values in certain situations (bug 12342)
Modified paths:
  • /trunk/phase3/includes/memcached-client.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/memcached-client.php
@@ -795,11 +795,6 @@
796796 $realkey = is_array($key) ? $key[1] : $key;
797797 for ($tries = 0; $tries<20; $tries++)
798798 {
799 - // temp logging for strange bug
800 - if( !isset($this->_buckets[$hv % $this->_bucketcount]) ) {
801 - wfDebugLog( "memcached", "Invalid bucket hash '$hv' from key '$realkey' given!" );
802 - continue;
803 - }
804799 $host = $this->_buckets[$hv % $this->_bucketcount];
805800 $sock = $this->sock_to_host($host);
806801 if (is_resource($sock)) {
@@ -807,6 +802,7 @@
808803 return $sock;
809804 }
810805 $hv += $this->_hashfunc($tries . $realkey);
 806+ $hv = $hv & 0x7fffffff; // don't let this pass the limit and go negative (bug 12342)
811807 }
812808
813809 return false;