4 This closes all connections (forces flush of input as well).
6 Maybe add a host specific, or key specific version?
8 The reason we send "quit" is that in case we have buffered IO, this
9 will force data to be completed.
12 void memcached_quit_server(memcached_server_st
*ptr
, uint8_t io_death
)
20 char buffer
[MEMCACHED_MAX_BUFFER
];
22 if (ptr
->root
->flags
& MEM_BINARY_PROTOCOL
)
24 protocol_binary_request_quit request
= {0};
25 request
.message
.header
.request
.magic
= PROTOCOL_BINARY_REQ
;
26 request
.message
.header
.request
.opcode
= PROTOCOL_BINARY_CMD_QUIT
;
27 request
.message
.header
.request
.datatype
= PROTOCOL_BINARY_RAW_BYTES
;
28 rc
= memcached_do(ptr
, request
.bytes
, sizeof(request
.bytes
), 1);
30 rc
= memcached_do(ptr
, "quit\r\n", 6, 1);
32 WATCHPOINT_ASSERT(rc
== MEMCACHED_SUCCESS
|| rc
== MEMCACHED_FETCH_NOTFINISHED
);
34 /* read until socket is closed, or there is an error
35 * closing the socket before all data is read
36 * results in server throwing away all data which is
40 memcached_io_read(ptr
, buffer
, sizeof(buffer
)/sizeof(*buffer
)))
43 memcached_io_close(ptr
, io_death
);
46 ptr
->write_buffer_offset
= 0;
47 ptr
->read_buffer_length
= 0;
48 ptr
->read_ptr
= ptr
->read_buffer
;
49 memcached_server_response_reset(ptr
);
53 void memcached_quit(memcached_st
*ptr
)
57 if (ptr
->hosts
== NULL
||
58 ptr
->number_of_hosts
== 0)
61 if (ptr
->hosts
&& ptr
->number_of_hosts
)
63 for (x
= 0; x
< ptr
->number_of_hosts
; x
++)
64 memcached_quit_server(&ptr
->hosts
[x
], 0);