I think the fix is incorrect for non-blocking connections. Now there is no timeout setting available for non-blocking connections to avoid a down server.
OPT_CONNECT_TIMEOUT is ignored, because of this section on line 22:
int timeout= ptr->root->connect_timeout;
if (ptr->root->flags.no_block == true)
timeout= -1;
...
error= poll(fds, 1, timeout);
# With OPT_NO_BLOCK:
$ php ~/test-nonblocking.php
SYSTEM ERROR after 189.00634503365s
SYSTEM ERROR after 378.03397202492s
SYSTEM ERROR after 567.05481410027s
567.05880594254
# Without OPT_NO_BLOCK:
$ php ~/test-blocking.php
A TIMEOUT OCCURRED after 0.042192935943604s
A TIMEOUT OCCURRED after 0.074706792831421s
A TIMEOUT OCCURRED after 0.089533805847168s
0.089677810668945
I think the fix is incorrect for non-blocking connections. Now there is no timeout setting available for non-blocking connections to avoid a down server.
OPT_CONNECT_TIMEOUT is ignored, because of this section on line 22:
int timeout= ptr->root- >connect_ timeout; >flags. no_block == true)
if (ptr->root-
timeout= -1;
...
error= poll(fds, 1, timeout);
I believe that makes the connect call blocking.
$options = array(
Memcached: :OPT_CONNECT_ TIMEOUT => 1, // milliseconds
Memcached: :OPT_POLL_ TIMEOUT => 1, // milliseconds
Memcached: :OPT_RECV_ TIMEOUT => 1000, // usec
Memcached: :OPT_SEND_ TIMEOUT => 1000, // usec
);
$m = new memcached(); $options) ; "192.168. 7.9", "11211");
$m->setOptions(
$m->addServer(
$start = microtime(true); ssage() . " after " . (microtime(true) - $start) . "s \n"; ssage() . " after " . (microtime(true) - $start) . "s \n"; ssage() . " after " . (microtime(true) - $start) . "s \n";
$m->get('test');
echo $m->getResultMe
$m->get('test');
echo $m->getResultMe
$m->get('test');
echo $m->getResultMe
$end = microtime(true);
echo $end - $start . "\n";
# With OPT_NO_BLOCK: nonblocking. php
$ php ~/test-
SYSTEM ERROR after 189.00634503365s
SYSTEM ERROR after 378.03397202492s
SYSTEM ERROR after 567.05481410027s
567.05880594254
# Without OPT_NO_BLOCK:
$ php ~/test-blocking.php
A TIMEOUT OCCURRED after 0.042192935943604s
A TIMEOUT OCCURRED after 0.074706792831421s
A TIMEOUT OCCURRED after 0.089533805847168s
0.089677810668945