Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Commit a0ff790

Browse files
committed
Checks for WSAWOULDBLOCK for ::recv, ::send
1 parent ccdab8e commit a0ff790

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

libmemcached/io.cc

+14-2
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,19 @@ static bool io_flush(memcached_instance_st* instance,
344344
ssize_t sent_length= ::send(instance->fd, local_write_ptr, write_length, flags);
345345
int local_errno= get_socket_errno(); // We cache in case memcached_quit_server() modifies errno
346346

347+
#ifdef _WIN32
348+
if ((local_errno == WSAENOTCONN)||(local_errno == WSAEWOULDBLOCK)) {
349+
local_errno = EAGAIN;
350+
}
351+
#endif
352+
347353
if (sent_length == SOCKET_ERROR)
348354
{
349355
#if 0 // @todo I should look at why we hit this bit of code hard frequently
350356
WATCHPOINT_ERRNO(get_socket_errno());
351357
WATCHPOINT_NUMBER(get_socket_errno());
352358
#endif
353-
switch (get_socket_errno())
359+
switch (local_errno)
354360
{
355361
case ENOBUFS:
356362
continue;
@@ -425,9 +431,15 @@ static memcached_return_t _io_fill(memcached_instance_st* instance)
425431
data_read= ::recv(instance->fd, instance->read_buffer, MEMCACHED_MAX_BUFFER, MSG_NOSIGNAL);
426432
int local_errno= get_socket_errno(); // We cache in case memcached_quit_server() modifies errno
427433

434+
#ifdef _WIN32
435+
if (local_errno == WSAEWOULDBLOCK) {
436+
local_errno = EAGAIN;
437+
}
438+
#endif
439+
428440
if (data_read == SOCKET_ERROR)
429441
{
430-
switch (get_socket_errno())
442+
switch (local_errno)
431443
{
432444
case EINTR: // We just retry
433445
continue;

0 commit comments

Comments
 (0)