r58186 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58185‎ | r58186 | r58187 >
Date:07:45, 27 October 2009
Author:midom
Status:ok
Tags:
Comment:
Merge everything from trunk (thats 58181-58185)
Modified paths:
  • /branches/wmf-deployment/includes/memcached-client.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/includes/memcached-client.php
@@ -258,11 +258,11 @@
259259 $this->_cache_sock = array();
260260 $this->_host_dead = array();
261261
262 - $this->_timeout_seconds = 1;
263 - $this->_timeout_microseconds = 0;
 262+ $this->_timeout_seconds = 0;
 263+ $this->_timeout_microseconds = 50000;
264264
265265 $this->_connect_timeout = 0.01;
266 - $this->_connect_attempts = 3;
 266+ $this->_connect_attempts = 2;
267267 }
268268
269269 // }}}
@@ -704,15 +704,6 @@
705705 $timeout = $this->_connect_timeout;
706706 $errno = $errstr = null;
707707 for ($i = 0; !$sock && $i < $this->_connect_attempts; $i++) {
708 - if ($i > 0) {
709 - # Sleep until the timeout, in case it failed fast
710 - $elapsed = microtime(true) - $t;
711 - if ( $elapsed < $timeout ) {
712 - usleep(($timeout - $elapsed) * 1e6);
713 - }
714 - $timeout *= 2;
715 - }
716 - $t = microtime(true);
717708 if ($this->_persistant == 1)
718709 {
719710 $sock = @pfsockopen($ip, $port, $errno, $errstr, $timeout);
@@ -746,6 +737,11 @@
747738 function _dead_sock ($sock)
748739 {
749740 $host = array_search($sock, $this->_cache_sock);
 741+ $this->_dead_host($host);
 742+ }
 743+
 744+ function _dead_host ($host)
 745+ {
750746 @list ($ip, /* $port */) = explode(":", $host);
751747 $this->_host_dead[$ip] = time() + 30 + intval(rand(0, 10));
752748 $this->_host_dead[$host] = $this->_host_dead[$ip];
@@ -853,7 +849,6 @@
854850 if (!$this->_safe_fwrite($sock, "$cmd $key $amt\r\n"))
855851 return $this->_dead_sock($sock);
856852
857 - stream_set_timeout($sock, 1, 0);
858853 $line = fgets($sock);
859854 $match = array();
860855 if (!preg_match('/^(\d+)/', $line, $match))
@@ -1014,7 +1009,7 @@
10151010 return null;
10161011
10171012 if (!$this->_connect_sock($sock, $host))
1018 - return $this->_dead_sock($host);
 1013+ return $this->_dead_host($host);
10191014
10201015 // Do not buffer writes
10211016 stream_set_write_buffer($sock, 0);

Status & tagging log