From: Brian Aker Date: Tue, 11 Dec 2007 00:58:51 +0000 (-0800) Subject: Removed recent regression issue with close() X-Git-Tag: 0.13~40 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=05b47c7cfee6b64985b651e308cb0c7aa307297a;p=awesomized%2Flibmemcached Removed recent regression issue with close() --- diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index 82a08ab7..f4c80d5c 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -143,7 +143,13 @@ static memcached_return tcp_connect(memcached_st *ptr, unsigned int server_key) flags= fcntl(ptr->hosts[server_key].fd, F_GETFL, 0); 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_TCP_NODELAY) diff --git a/lib/memcached_io.c b/lib/memcached_io.c index daf64755..85a27d96 100644 --- a/lib/memcached_io.c +++ b/lib/memcached_io.c @@ -150,36 +150,9 @@ ssize_t memcached_io_write(memcached_st *ptr, unsigned int server_key, memcached_return memcached_io_close(memcached_st *ptr, unsigned int server_key) { - memcached_return rc; - - rc= MEMCACHED_SUCCESS; - if (ptr->flags & MEM_NO_BLOCK) - { - int error; - struct pollfd fds[1]; - short flags= 0; - - flags= POLLHUP | POLLERR; - - memset(&fds, 0, sizeof(struct pollfd)); - fds[0].fd= ptr->hosts[server_key].fd; - fds[0].events= flags; - fds[0].revents= 0; - - error= poll(fds, 1, ptr->poll_timeout == -1 ? 100 : ptr->poll_timeout); - - if (error == -1) - { - memcached_quit_server(ptr, server_key, 1); - return MEMCACHED_FAILURE; - } - else if (error == 0) - return MEMCACHED_FAILURE; /* Timeout occurred */ - } - close(ptr->hosts[server_key].fd); - return rc; + return MEMCACHED_SUCCESS; } static ssize_t io_flush(memcached_st *ptr, unsigned int server_key,