Index: branches/wmf-deployment/includes/memcached-client.php |
— | — | @@ -258,11 +258,11 @@ |
259 | 259 | $this->_cache_sock = array(); |
260 | 260 | $this->_host_dead = array(); |
261 | 261 | |
262 | | - $this->_timeout_seconds = 1; |
263 | | - $this->_timeout_microseconds = 0; |
| 262 | + $this->_timeout_seconds = 0; |
| 263 | + $this->_timeout_microseconds = 50000; |
264 | 264 | |
265 | 265 | $this->_connect_timeout = 0.01; |
266 | | - $this->_connect_attempts = 3; |
| 266 | + $this->_connect_attempts = 2; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // }}} |
— | — | @@ -704,15 +704,6 @@ |
705 | 705 | $timeout = $this->_connect_timeout; |
706 | 706 | $errno = $errstr = null; |
707 | 707 | 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); |
717 | 708 | if ($this->_persistant == 1) |
718 | 709 | { |
719 | 710 | $sock = @pfsockopen($ip, $port, $errno, $errstr, $timeout); |
— | — | @@ -746,6 +737,11 @@ |
747 | 738 | function _dead_sock ($sock) |
748 | 739 | { |
749 | 740 | $host = array_search($sock, $this->_cache_sock); |
| 741 | + $this->_dead_host($host); |
| 742 | + } |
| 743 | + |
| 744 | + function _dead_host ($host) |
| 745 | + { |
750 | 746 | @list ($ip, /* $port */) = explode(":", $host); |
751 | 747 | $this->_host_dead[$ip] = time() + 30 + intval(rand(0, 10)); |
752 | 748 | $this->_host_dead[$host] = $this->_host_dead[$ip]; |
— | — | @@ -853,7 +849,6 @@ |
854 | 850 | if (!$this->_safe_fwrite($sock, "$cmd $key $amt\r\n")) |
855 | 851 | return $this->_dead_sock($sock); |
856 | 852 | |
857 | | - stream_set_timeout($sock, 1, 0); |
858 | 853 | $line = fgets($sock); |
859 | 854 | $match = array(); |
860 | 855 | if (!preg_match('/^(\d+)/', $line, $match)) |
— | — | @@ -1014,7 +1009,7 @@ |
1015 | 1010 | return null; |
1016 | 1011 | |
1017 | 1012 | if (!$this->_connect_sock($sock, $host)) |
1018 | | - return $this->_dead_sock($host); |
| 1013 | + return $this->_dead_host($host); |
1019 | 1014 | |
1020 | 1015 | // Do not buffer writes |
1021 | 1016 | stream_set_write_buffer($sock, 0); |