From: Brian Aker Date: Tue, 11 Dec 2007 02:34:49 +0000 (-0800) Subject: Cleanup of linger call. X-Git-Tag: 0.13~39 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f45cff13d17432059886e6f426d3c8c4d1f23732;p=m6w6%2Flibmemcached Cleanup of linger call. --- diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index f4c80d5c..fd4518d5 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -145,31 +145,47 @@ static memcached_return tcp_connect(memcached_st *ptr, unsigned int server_key) if (flags != -1) { (void)fcntl(ptr->hosts[server_key].fd, F_SETFL, flags | O_NONBLOCK); - - flags= 1; - setsockopt(ptr->hosts[server_key].fd, IPPROTO_TCP, SO_LINGER, - &flags, (socklen_t)sizeof(int)); } } + if (ptr->flags & MEM_NO_BLOCK) + { + int error; + struct linger linger; + + linger.l_onoff= 1; + linger.l_linger= 400; + error= setsockopt(ptr->hosts[server_key].fd, SOL_SOCKET, SO_LINGER, + &linger, (socklen_t)sizeof(struct linger)); + WATCHPOINT_ASSERT(error == 0); + } + if (ptr->flags & MEM_TCP_NODELAY) { int flag= 1; + int error; - setsockopt(ptr->hosts[server_key].fd, IPPROTO_TCP, TCP_NODELAY, - &flag, (socklen_t)sizeof(int)); + error= setsockopt(ptr->hosts[server_key].fd, IPPROTO_TCP, TCP_NODELAY, + &flag, (socklen_t)sizeof(int)); + WATCHPOINT_ASSERT(error == 0); } if (ptr->send_size) { - setsockopt(ptr->hosts[server_key].fd, SOL_SOCKET, SO_SNDBUF, - &ptr->send_size, (socklen_t)sizeof(int)); + int error; + + error= setsockopt(ptr->hosts[server_key].fd, SOL_SOCKET, SO_SNDBUF, + &ptr->send_size, (socklen_t)sizeof(int)); + WATCHPOINT_ASSERT(error == 0); } if (ptr->recv_size) { - setsockopt(ptr->hosts[server_key].fd, SOL_SOCKET, SO_SNDBUF, - &ptr->recv_size, (socklen_t)sizeof(int)); + int error; + + error= setsockopt(ptr->hosts[server_key].fd, SOL_SOCKET, SO_SNDBUF, + &ptr->recv_size, (socklen_t)sizeof(int)); + WATCHPOINT_ASSERT(error == 0); } /* connect to server */ @@ -193,6 +209,7 @@ test_connect: } ptr->connected++; } + WATCHPOINT_ASSERT(ptr->hosts[server_key].stack_responses == 0); } diff --git a/lib/memcached_io.c b/lib/memcached_io.c index 85a27d96..de3eda32 100644 --- a/lib/memcached_io.c +++ b/lib/memcached_io.c @@ -150,6 +150,19 @@ ssize_t memcached_io_write(memcached_st *ptr, unsigned int server_key, memcached_return memcached_io_close(memcached_st *ptr, unsigned int server_key) { + if (ptr->flags & MEM_NO_BLOCK && 0) + { + int sock_size; + int error; + socklen_t sock_length; + + error= getsockopt(ptr->hosts[server_key].fd, IPPROTO_TCP, SO_LINGER, + &sock_size, &sock_length); + + WATCHPOINT_NUMBER(error); + WATCHPOINT_NUMBER(sock_size); + } + close(ptr->hosts[server_key].fd); return MEMCACHED_SUCCESS;