From: Brian Aker Date: Tue, 29 Jun 2010 16:39:45 +0000 (-0700) Subject: Optimization around connect. X-Git-Tag: 0.41~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2a1c0d59386b12f25cfc0b5d786ca7b904328833;p=m6w6%2Flibmemcached Optimization around connect. --- diff --git a/libmemcached/behavior.c b/libmemcached/behavior.c index f1573b60..2f5311e5 100644 --- a/libmemcached/behavior.c +++ b/libmemcached/behavior.c @@ -55,6 +55,7 @@ memcached_return_t memcached_behavior_set(memcached_st *ptr, ptr->server_failure_limit= (uint32_t)data; break; case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: + memcached_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol if (data) { ptr->flags.verify_key= false; diff --git a/libmemcached/connect.c b/libmemcached/connect.c index 3002727d..bf93dff1 100644 --- a/libmemcached/connect.c +++ b/libmemcached/connect.c @@ -470,6 +470,10 @@ void set_last_disconnected_host(memcached_server_write_instance_st ptr) memcached_return_t memcached_connect(memcached_server_write_instance_st ptr) { memcached_return_t rc= MEMCACHED_NO_SERVERS; + + if (ptr->fd > -1) + return MEMCACHED_SUCCESS; + LIBMEMCACHED_MEMCACHED_CONNECT_START(); /* both retry_timeout and server_failure_limit must be set in order to delay retrying a server on error. */