From: Andre Cruz Date: Mon, 8 Mar 2010 17:23:29 +0000 (+0000) Subject: Added missing constant. X-Git-Tag: 0.40~16^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ff452398ec3114d6af77aa5d2d77f53b18d980e3;p=m6w6%2Flibmemcached Added missing constant. Set keepalive before keepidle. --- diff --git a/libmemcached/behavior.c b/libmemcached/behavior.c index e250241b..7ca97e3a 100644 --- a/libmemcached/behavior.c +++ b/libmemcached/behavior.c @@ -157,6 +157,10 @@ memcached_return_t memcached_behavior_set(memcached_st *ptr, ptr->recv_size= (int32_t)data; memcached_quit(ptr); break; + case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: + ptr->tcp_keepidle= (uint32_t)data; + memcached_quit(ptr); + break; case MEMCACHED_BEHAVIOR_USER_DATA: return MEMCACHED_FAILURE; case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: @@ -292,6 +296,8 @@ uint64_t memcached_behavior_get(memcached_st *ptr, return (uint64_t)ptr->snd_timeout; case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: return (uint64_t)ptr->rcv_timeout; + case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: + return (uint64_t)ptr->tcp_keepidle; case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: { int sock_size= 0; diff --git a/libmemcached/connect.c b/libmemcached/connect.c index 67ceacab..da72c8e3 100644 --- a/libmemcached/connect.c +++ b/libmemcached/connect.c @@ -85,20 +85,6 @@ static memcached_return_t set_socket_options(memcached_server_st *ptr) } #endif -#ifdef TCP_KEEPIDLE - if (ptr->root->tcp_keepidle) - { - int flag= 1; - int error; - - error= setsockopt(ptr->fd, IPPROTO_TCP, TCP_KEEPIDLE, - &flag, (socklen_t)sizeof(int)); - WATCHPOINT_ASSERT(error == 0); - if (error) - return MEMCACHED_FAILURE; - } -#endif - if (ptr->root->flags.no_block) { int error; @@ -137,6 +123,19 @@ static memcached_return_t set_socket_options(memcached_server_st *ptr) return MEMCACHED_FAILURE; } +#ifdef TCP_KEEPIDLE + if (ptr->root->tcp_keepidle > 0) + { + int error; + + error= setsockopt(ptr->fd, IPPROTO_TCP, TCP_KEEPIDLE, + &ptr->root->tcp_keepidle, (socklen_t)sizeof(int)); + WATCHPOINT_ASSERT(error == 0); + if (error) + return MEMCACHED_FAILURE; + } +#endif + if (ptr->root->send_size > 0) { int error; diff --git a/libmemcached/constants.h b/libmemcached/constants.h index 6405df29..b215b328 100644 --- a/libmemcached/constants.h +++ b/libmemcached/constants.h @@ -116,6 +116,7 @@ typedef enum { MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, MEMCACHED_BEHAVIOR_CORK, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, + MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, MEMCACHED_BEHAVIOR_MAX } memcached_behavior_t;