X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fquit.c;h=8b5acf67d1f056727f38328241af7b0c4abac6c4;hb=9979e3f8206c764a881550dda41a444f005206f3;hp=4abadb94c60bbaa2afe84705232353c5a0a58f9f;hpb=7c986323bd4eece0d805f4df17eb03ea094f84f6;p=m6w6%2Flibmemcached diff --git a/libmemcached/quit.c b/libmemcached/quit.c index 4abadb94..8b5acf67 100644 --- a/libmemcached/quit.c +++ b/libmemcached/quit.c @@ -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); @@ -53,28 +53,35 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death) ptr->server_failure_counter= 0; } memcached_io_close(ptr); - - ptr->fd= -1; - ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0); - ptr->read_buffer_length= 0; - ptr->read_ptr= ptr->read_buffer; - memcached_server_response_reset(ptr); } - if(io_death) ptr->server_failure_counter++; + ptr->fd= -1; + ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0); + ptr->read_buffer_length= 0; + ptr->read_ptr= ptr->read_buffer; + memcached_server_response_reset(ptr); + + if (io_death) + { + ptr->server_failure_counter++; + } } void memcached_quit(memcached_st *ptr) { - unsigned int x; + uint32_t x; - if (ptr->hosts == NULL || - ptr->number_of_hosts == 0) + if (memcached_server_count(ptr) == 0) return; - if (ptr->hosts && ptr->number_of_hosts) + if (memcached_server_count(ptr)) { - for (x= 0; x < ptr->number_of_hosts; x++) - memcached_quit_server(&ptr->hosts[x], 0); + for (x= 0; x < memcached_server_count(ptr); x++) + { + memcached_server_instance_st *instance= + memcached_server_instance_fetch(ptr, x); + + memcached_quit_server(instance, 0); + } } }