Cleanup on uint8 to bool for quit.
[m6w6/libmemcached] / libmemcached / quit.c
index a8f70402062d7c1e87a486a2ac54959827091981..8b5acf67d1f056727f38328241af7b0c4abac6c4 100644 (file)
@@ -9,11 +9,11 @@
   will force data to be completed.
 */
 
-void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
+void memcached_quit_server(memcached_server_st *ptr, bool io_death)
 {
   if (ptr->fd != -1)
   {
-    if (io_death == 0 && ptr->type != MEMCACHED_CONNECTION_UDP)
+    if (io_death == false && ptr->type != MEMCACHED_CONNECTION_UDP)
     {
       memcached_return_t rc;
       char buffer[MEMCACHED_MAX_BUFFER];
@@ -24,11 +24,11 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
         request.message.header.request.magic = PROTOCOL_BINARY_REQ;
         request.message.header.request.opcode = PROTOCOL_BINARY_CMD_QUIT;
         request.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES;
-        rc= memcached_do(ptr, request.bytes, sizeof(request.bytes), 1);
+        rc= memcached_do(ptr, request.bytes, sizeof(request.bytes), true);
       }
       else
       {
-        rc= memcached_do(ptr, "quit\r\n", 6, 1);
+        rc= memcached_do(ptr, "quit\r\n", sizeof("quit\r\n"), true);
       }
 
       WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
@@ -61,7 +61,7 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
   ptr->read_ptr= ptr->read_buffer;
   memcached_server_response_reset(ptr);
 
-  if(io_death)
+  if (io_death)
   {
     ptr->server_failure_counter++;
   }
@@ -69,15 +69,19 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
 
 void memcached_quit(memcached_st *ptr)
 {
-  unsigned int x;
+  uint32_t x;
 
-  if (ptr->hosts == NULL ||
-      memcached_server_count(ptr) == 0)
+  if (memcached_server_count(ptr) == 0)
     return;
 
-  if (ptr->hosts && memcached_server_count(ptr))
+  if (memcached_server_count(ptr))
   {
     for (x= 0; x < memcached_server_count(ptr); x++)
-      memcached_quit_server(&ptr->hosts[x], 0);
+    {
+      memcached_server_instance_st *instance=
+        memcached_server_instance_fetch(ptr, x);
+
+      memcached_quit_server(instance, 0);
+    }
   }
 }