Non-blocking IO :)
[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 void memcached_quit(memcached_st *ptr)
12 {
13 unsigned int x;
14
15 if (ptr->hosts)
16 {
17 for (x= 0; x < ptr->number_of_hosts; x++)
18 {
19 if (ptr->hosts[x].fd != -1)
20 {
21 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
22
23 if (ptr->flags & MEM_NO_BLOCK)
24 memcached_io_write(ptr, x, "quit\r\n", 6, 1);
25 close(ptr->hosts[x].fd);
26 ptr->hosts[x].fd= -1;
27 }
28 }
29 }
30
31 ptr->connected= 0;
32 }