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)
{
...
case 0:
if (loop_max==1) { return MEMCACHED_TIMEOUT;
} continue;
// A real error occurred and we need to completely bail
...
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
...