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:
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;
}
#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;
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;
MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ,
MEMCACHED_BEHAVIOR_CORK,
MEMCACHED_BEHAVIOR_TCP_KEEPALIVE,
+ MEMCACHED_BEHAVIOR_TCP_KEEPIDLE,
MEMCACHED_BEHAVIOR_MAX
} memcached_behavior_t;