Connect in a blocking mode hangs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libmemcached |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
If the connect is performed in a blocking mode, then there is no timeout on connection. Therefor, trying to connect to a non-reachable host will timeout in a few minutes instead of values specified.
If I remove the around connect.c:333 then connection works well:
if (ptr->root-
How to reproduce:
1. pick an unreachable IP, like, 10.2.3.4 routed via 127.0.0.1.
2. Use the following simple (php, unfortunately) code:
$_memcache = new Memcached();
$_memcache-
$_memcache-
$_memcache-
$_memcache-
$_memcache-
$_memcache-
$_memcache-
printf(
$result = $_memcache-
printf(
Expected result: timeout.
Actual result: timeout in something like ~6 minutes.
Actual result with the mentioned line removed: timeout.
Was tested on libmemcached 0.40, memcached php extension 1.0.2 on php 5.3.2 on Mac OS X 10.6.3.
Related branches
Changed in libmemcached: | |
status: | New → Fix Committed |
Changed in libmemcached: | |
status: | Fix Committed → Fix Released |
It turns out this is not the best way to fix the problem. What I had to do is to set no_block to true, bring back the above two lines, but add the following in connect.c:
...
int error= poll(fds, 1, timeout);
switch (error)
return MEMCACHED_TIMEOUT;
continue;
{
...
case 0:
if (loop_max==1) {
}
// A real error occurred and we need to completely bail
...