X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached_connect.c;h=f4c80d5cc53d97e612f318a8694b825c2b7d6957;hb=05b47c7cfee6b64985b651e308cb0c7aa307297a;hp=672b1c23b65e5ce4f1d0c29c9502352186425d42;hpb=666a820df3605bf92a4ffefed6ec3b1649f37291;p=m6w6%2Flibmemcached diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index 672b1c23..f4c80d5c 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -1,13 +1,5 @@ #include "common.h" -#include -#include -#include -#include -#include -#include -#include - static memcached_return set_hostinfo(memcached_server_st *server) { struct addrinfo *ai; @@ -140,17 +132,24 @@ static memcached_return tcp_connect(memcached_st *ptr, unsigned int server_key) use->ai_protocol)) < 0) { ptr->cached_errno= errno; + WATCHPOINT_ERRNO(errno); return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; } - /* For the moment, not getting a nonblocking mode will note be fatal */ + /* For the moment, not getting a nonblocking mode will not be fatal */ if (ptr->flags & MEM_NO_BLOCK) { int flags; 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)