Fix problem with bumping the command counter _before_ connecting to the server
[m6w6/libmemcached] / libmemcached / flush_buffers.c
1 #include "common.h"
2
3 memcached_return_t memcached_flush_buffers(memcached_st *mem)
4 {
5 memcached_return_t ret= MEMCACHED_SUCCESS;
6
7 for (uint32_t x= 0; x < mem->number_of_hosts; ++x)
8 if (mem->hosts[x].write_buffer_offset != 0)
9 {
10 if (mem->hosts[x].fd == -1 &&
11 (ret= memcached_connect(&mem->hosts[x])) != MEMCACHED_SUCCESS)
12 {
13 WATCHPOINT_ERROR(ret);
14 return ret;
15 }
16 if (memcached_io_write(&mem->hosts[x], NULL, 0, 1) == -1)
17 ret= MEMCACHED_SOME_ERRORS;
18 }
19
20 return ret;
21 }