Assert in debug to look for random allocation in get.
[awesomized/libmemcached] / lib / memcached_quit.c
1 #include "common.h"
2
3 /*
4 This closes all connections (forces flush of input as well).
5
6 Maybe add a host specific, or key specific version?
7
8 The reason we send "quit" is that in case we have buffered IO, this
9 will force data to be completed.
10 */
11
12 void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
13 {
14 if (ptr->fd != -1)
15 {
16 if (io_death == 0)
17 {
18 memcached_return rc;
19 rc= memcached_do(ptr, "quit\r\n", 6, 1);
20 WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
21
22 memcached_io_close(ptr);
23 }
24
25 ptr->fd= -1;
26 ptr->write_buffer_offset= 0;
27 ptr->read_buffer_length= 0;
28 ptr->read_ptr= ptr->read_buffer;
29 memcached_server_response_reset(ptr);
30 }
31 }
32
33 void memcached_quit(memcached_st *ptr)
34 {
35 unsigned int x;
36
37 if (ptr->hosts == NULL ||
38 ptr->number_of_hosts == 0)
39 return;
40
41 if (ptr->hosts && ptr->number_of_hosts)
42 {
43 for (x= 0; x < ptr->number_of_hosts; x++)
44 memcached_quit_server(&ptr->hosts[x], 0);
45 }
46 }