From: Nicolas Van Eenaeme Date: Wed, 20 Nov 2013 14:39:27 +0000 (+0100) Subject: Small bugfixes for errno (since memcached_quit_server() modifies errno) X-Git-Tag: 1.0.18~7^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=eeb331250b498d8ba2c57d0646cb2953072a1a07;p=awesomized%2Flibmemcached Small bugfixes for errno (since memcached_quit_server() modifies errno) --- diff --git a/libmemcached/io.cc b/libmemcached/io.cc index 8796d503..e9d3ad39 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -342,6 +342,7 @@ static bool io_flush(memcached_instance_st* instance, } ssize_t sent_length= ::send(instance->fd, local_write_ptr, write_length, flags); + int local_errno= get_socket_errno(); // We cache in case memcached_quit_server() modifies errno if (sent_length == SOCKET_ERROR) { @@ -381,14 +382,14 @@ static bool io_flush(memcached_instance_st* instance, } memcached_quit_server(instance, true); - error= memcached_set_errno(*instance, get_socket_errno(), MEMCACHED_AT); + error= memcached_set_errno(*instance, local_errno, MEMCACHED_AT); return false; } case ENOTCONN: case EPIPE: default: memcached_quit_server(instance, true); - error= memcached_set_errno(*instance, get_socket_errno(), MEMCACHED_AT); + error= memcached_set_errno(*instance, local_errno, MEMCACHED_AT); WATCHPOINT_ASSERT(instance->fd == INVALID_SOCKET); return false; } @@ -422,6 +423,8 @@ static memcached_return_t _io_fill(memcached_instance_st* instance) do { data_read= ::recv(instance->fd, instance->read_buffer, MEMCACHED_MAX_BUFFER, MSG_NOSIGNAL); + int local_errno= get_socket_errno(); // We cache in case memcached_quit_server() modifies errno + if (data_read == SOCKET_ERROR) { switch (get_socket_errno()) @@ -460,7 +463,7 @@ static memcached_return_t _io_fill(memcached_instance_st* instance) case ECONNREFUSED: default: memcached_quit_server(instance, true); - memcached_set_errno(*instance, get_socket_errno(), MEMCACHED_AT); + memcached_set_errno(*instance, local_errno, MEMCACHED_AT); break; }