Cleanup values for future use of memcached_server_free()
author <brian@gir-3.local> <>
Mon, 8 Sep 2008 23:38:09 +0000 (16:38 -0700)
committer <brian@gir-3.local> <>
Mon, 8 Sep 2008 23:38:09 +0000 (16:38 -0700)
libmemcached/memcached_server.c

index 6dff69408571b4c0f459b60241621878709b584c..1ee60101a8d32f07937ffdae1d9b04ebcf765210 100644 (file)
@@ -27,6 +27,18 @@ memcached_server_st *memcached_server_create(memcached_st *memc, memcached_serve
 
 void memcached_server_free(memcached_server_st *ptr)
 {
+  memcached_return rc;
+  WATCHPOINT_ASSERT(ptr->is_allocated != MEMCACHED_NOT_ALLOCATED);
+
+  rc= memcached_io_close(ptr);
+  WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS);
+
+  if (ptr->address_info)
+  {
+    freeaddrinfo(ptr->address_info);
+    ptr->address_info= NULL;
+  }
+
   if (ptr->is_allocated == MEMCACHED_ALLOCATED)
   {
     if (ptr->root && ptr->root->call_free)