=== modified file 'libmemcached/fetch.cc' --- libmemcached/fetch.cc 2013-03-31 23:24:29 +0000 +++ libmemcached/fetch.cc 2014-01-19 22:42:02 +0000 @@ -1,5 +1,5 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * + * * Libmemcached library * * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ @@ -37,8 +37,8 @@ #include -char *memcached_fetch(memcached_st *shell, char *key, size_t *key_length, - size_t *value_length, +char *memcached_fetch(memcached_st *shell, char *key, size_t *key_length, + size_t *value_length, uint32_t *flags, memcached_return_t *error) { @@ -194,6 +194,7 @@ *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]; @@ -203,6 +204,11 @@ { continue; } + else if (*error == MEMCACHED_CONNECTION_FAILURE) + { + connection_failures = true; + continue; + } else if (*error == MEMCACHED_SUCCESS) { result->count++; @@ -230,6 +236,14 @@ { *error= MEMCACHED_NOTFOUND; } + /* 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. */ + else if (connection_failures) + { + *error= MEMCACHED_CONNECTION_FAILURE; + } else if (*error == MEMCACHED_SUCCESS) { *error= MEMCACHED_END; @@ -253,7 +267,7 @@ return NULL; } -memcached_return_t memcached_fetch_execute(memcached_st *shell, +memcached_return_t memcached_fetch_execute(memcached_st *shell, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks) === modified file 'libmemcached/quit.cc' --- libmemcached/quit.cc 2013-03-31 23:24:29 +0000 +++ libmemcached/quit.cc 2014-01-19 22:38:34 +0000 @@ -1,5 +1,5 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * + * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ @@ -120,7 +120,12 @@ instance->close_socket(); - if (io_death) + // 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). + if (io_death and memcached_is_udp(ptr->root)) { memcached_mark_server_for_timeout(instance); }