*error= MEMCACHED_MAXIMUM_RETURN; // We use this to see if we ever go into the loop
memcached_instance_st *server;
memcached_return_t read_ret= MEMCACHED_SUCCESS;
+ bool connection_failures= false;
while ((server= memcached_io_get_readable_server(ptr, read_ret)))
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
{
continue;
}
+ else if (*error == MEMCACHED_CONNECTION_FAILURE)
+ {
+ connection_failures= true;
+ continue;
+ }
else if (*error == MEMCACHED_SUCCESS)
{
result->count++;
{
*error= MEMCACHED_NOTFOUND;
}
+ else if (connection_failures)
+ {
+ /*
+ If we have a connection failure to some servers, the caller may
+ wish to treat that differently to getting a definitive NOT_FOUND
+ from all servers, so return MEMCACHED_CONNECTION_FAILURE to allow
+ that.
+ */
+ *error= MEMCACHED_CONNECTION_FAILURE;
+ }
else if (*error == MEMCACHED_SUCCESS)
{
*error= MEMCACHED_END;
instance->close_socket();
- if (io_death)
+ if (io_death and memcached_is_udp(instance->root))
{
+ /*
+ If using UDP, we should stop using the server briefly on every IO
+ failure. If using TCP, it may be that the connection went down a
+ short while ago (e.g. the server failed) and we've only just
+ noticed, so we should only set the retry timeout on a connect
+ failure (which doesn't call this method).
+ */
memcached_mark_server_for_timeout(instance);
}
}