Solution for cases where next has been set to NULL.
authorBrian Aker <brian@tangent.org>
Sat, 10 Sep 2011 05:16:02 +0000 (22:16 -0700)
committerBrian Aker <brian@tangent.org>
Sat, 10 Sep 2011 05:16:02 +0000 (22:16 -0700)
libmemcached/connect.cc

index 589c40c51dd06fff0f9230a18eaf4e768e42dade..1c4ea913689ca54b513d7a8ded2660c9ca13100a 100644 (file)
@@ -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)
   {