From dcddc0964b560a3494ee079822a94074ea94b832 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Fri, 9 Sep 2011 22:16:02 -0700 Subject: [PATCH] Solution for cases where next has been set to NULL. --- libmemcached/connect.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 589c40c5..1c4ea913 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -400,9 +400,13 @@ static memcached_return_t network_connect(memcached_server_st *server) WATCHPOINT_ASSERT(server->fd == INVALID_SOCKET); WATCHPOINT_ASSERT(server->cursor_active == 0); + /* + We want to check both of these because if address_info_next has been fully tried, we want to do a new lookup to make sure we have picked up on any new DNS information. + */ if (server->address_info == NULL or server->address_info_next == NULL) { WATCHPOINT_ASSERT(server->state == MEMCACHED_SERVER_STATE_NEW); + server->address_info_next= NULL; memcached_return_t rc; uint32_t counter= 5; while (--counter) @@ -428,6 +432,12 @@ static memcached_return_t network_connect(memcached_server_st *server) } } + if (server->address_info_next == NULL) + { + server->address_info_next= server->address_info; + server->state= MEMCACHED_SERVER_STATE_ADDRINFO; + } + /* Create the socket */ while (server->address_info_next and server->fd == INVALID_SOCKET) { -- 2.30.2