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 && ptr->options.is_shutting_down == false)
{
memcached_return_t rc;
char buffer[MEMCACHED_MAX_BUFFER];
+ ptr->options.is_shutting_down= true;
+
if (ptr->root->flags.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);
+ 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);
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;
+ ptr->options.is_shutting_down= false;
memcached_server_response_reset(ptr);
- if(io_death)
+ if (io_death)
{
ptr->server_failure_counter++;
}
{
for (x= 0; x < memcached_server_count(ptr); x++)
{
- memcached_server_instance_st *instance=
+ memcached_server_write_instance_st instance=
memcached_server_instance_fetch(ptr, x);
- memcached_quit_server(instance, 0);
+ memcached_quit_server(instance, false);
}
}
}