X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached_connect.c;h=57274be2086a17d35192dd98bd68c54716de2507;hb=2c7a6aaf4a69aab11206078afcd3355271ddf128;hp=f95b8e7d752f3115298cf85310b63c1d93a9bb69;hpb=b9298b65419d873299e010afa0f4eca2c8259969;p=awesomized%2Flibmemcached diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index f95b8e7d..57274be2 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -4,6 +4,7 @@ #include #include #include +#include memcached_return memcached_real_connect(memcached_st *ptr, unsigned int server_key) { @@ -12,8 +13,14 @@ memcached_return memcached_real_connect(memcached_st *ptr, unsigned int server_k if (ptr->hosts[server_key].fd == -1) { + /* Old connection junk still is in the structure */ + assert(ptr->hosts[server_key].stack_responses == 0); + if ((h= gethostbyname(ptr->hosts[server_key].hostname)) == NULL) + { + ptr->my_errno= h_errno; return MEMCACHED_HOST_LOCKUP_FAILURE; + } servAddr.sin_family= h->h_addrtype; memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length); @@ -56,6 +63,7 @@ test_connect: { switch (errno) { /* We are spinning waiting on connect */ + case EALREADY: case EINPROGRESS: case EINTR: goto test_connect; @@ -63,10 +71,11 @@ test_connect: break; default: ptr->my_errno= errno; - return MEMCACHED_HOST_LOCKUP_FAILURE; + return MEMCACHED_ERRNO; } ptr->connected++; } + assert(ptr->hosts[server_key].stack_responses == 0); } return MEMCACHED_SUCCESS;