merge.
[m6w6/libmemcached] / libmemcached / flush_buffers.c
1 #include "common.h"
2
3 memcached_return_t memcached_flush_buffers(memcached_st *memc)
4 {
5 memcached_return_t ret= MEMCACHED_SUCCESS;
6
7 for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
8 {
9 memcached_server_write_instance_st instance=
10 memcached_server_instance_fetch(memc, x);
11
12 if (instance->write_buffer_offset != 0)
13 {
14 if (instance->fd == -1 &&
15 (ret= memcached_connect(instance)) != MEMCACHED_SUCCESS)
16 {
17 WATCHPOINT_ERROR(ret);
18 return ret;
19 }
20 if (memcached_io_write(instance, NULL, 0, true) == -1)
21 ret= MEMCACHED_SOME_ERRORS;
22 }
23 }
24
25 return ret;
26 }