From: Brian Aker Date: Tue, 15 Sep 2009 21:09:32 +0000 (-0700) Subject: Fix for linger behavior X-Git-Tag: 0.32~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=92a7b5f31623b3e8a7283a98fcef3f78a771bdf1;p=m6w6%2Flibmemcached Fix for linger behavior --- diff --git a/ChangeLog b/ChangeLog index 45cb774f..581c0ab9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * Change of behavior where linger is only modified for no-block and then + it is set to zero. * Added Twitter's memcached_server_error() functions. * Fix for OSX compiles in development builds. * Updated C++ interface. diff --git a/libmemcached/memcached_behavior.c b/libmemcached/memcached_behavior.c index 5241c3c8..dd988489 100644 --- a/libmemcached/memcached_behavior.c +++ b/libmemcached/memcached_behavior.c @@ -225,17 +225,11 @@ uint64_t memcached_behavior_get(memcached_st *ptr, temp_flag= MEM_USE_SORT_HOSTS; break; case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: - { - return (uint64_t)ptr->poll_timeout; - } + return (uint64_t)ptr->poll_timeout; case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: - { - return (uint64_t)ptr->connect_timeout; - } + return (uint64_t)ptr->connect_timeout; case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: - { - return (uint64_t)ptr->retry_timeout; - } + return (uint64_t)ptr->retry_timeout; case MEMCACHED_BEHAVIOR_SND_TIMEOUT: return (uint64_t)ptr->snd_timeout; case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: diff --git a/libmemcached/memcached_connect.c b/libmemcached/memcached_connect.c index 93738f4a..833ad0ef 100644 --- a/libmemcached/memcached_connect.c +++ b/libmemcached/memcached_connect.c @@ -81,12 +81,13 @@ static memcached_return set_socket_options(memcached_server_st *ptr) } #endif + if (ptr->root->flags & MEM_NO_BLOCK) { int error; struct linger linger; linger.l_onoff= 1; - linger.l_linger= MEMCACHED_DEFAULT_TIMEOUT; + linger.l_linger= 0; /* By default on close() just drop the socket */ error= setsockopt(ptr->fd, SOL_SOCKET, SO_LINGER, &linger, (socklen_t)sizeof(struct linger)); WATCHPOINT_ASSERT(error == 0);