Merge in updates (including removal of some depcrated bits from the examples).
[awesomized/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
21 if (memcached_io_write(instance, NULL, 0, true) == -1)
22 {
23 ret= MEMCACHED_SOME_ERRORS;
24 }
25 }
26 }
27
28 return ret;
29 }