X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_quit.c;h=c30b1ccdfc6923a91734deeb954b2c9598fff352;hb=8a0a471e3b703274de52e9d61c8d0c4ee714e068;hp=9874bb6ea45f66ad9a1876dabf7ae729ea53e633;hpb=34a8c3858f30b02568c87f56a827f618aba6d6be;p=awesomized%2Flibmemcached diff --git a/libmemcached/memcached_quit.c b/libmemcached/memcached_quit.c index 9874bb6e..c30b1ccd 100644 --- a/libmemcached/memcached_quit.c +++ b/libmemcached/memcached_quit.c @@ -19,9 +19,18 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death) ssize_t read_length; char buffer[MEMCACHED_MAX_BUFFER]; - rc= memcached_do(ptr, "quit\r\n", 6, 1); - WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED); + if (ptr->root->flags & MEM_BINARY_PROTOCOL) + { + protocol_binary_request_quit request = {.bytes= {0}}; + 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); + } else + rc= memcached_do(ptr, "quit\r\n", 6, 1); + WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED); + /* read until socket is closed, or there is an error * closing the socket before all data is read * results in server throwing away all data which is @@ -29,12 +38,9 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death) */ while ((read_length= memcached_io_read(ptr, buffer, sizeof(buffer)/sizeof(*buffer))) - > 0) - { - ; - } - memcached_io_close(ptr); + > 0); } + memcached_io_close(ptr, io_death); ptr->fd= -1; ptr->write_buffer_offset= 0;