X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fbehavior.c;h=f88f0a771c1f556d926a20322cfb776da7f46789;hb=9bcd450682e20f0d704d86948bbb0880e414dfb4;hp=2f5311e5a01ddac70d96cc9c36576983d3b66f79;hpb=2a1c0d59386b12f25cfc0b5d786ca7b904328833;p=m6w6%2Flibmemcached diff --git a/libmemcached/behavior.c b/libmemcached/behavior.c index 2f5311e5..f88f0a77 100644 --- a/libmemcached/behavior.c +++ b/libmemcached/behavior.c @@ -12,8 +12,6 @@ #include "common.h" #include #include -#include -#include static bool set_flag(uint64_t data) { @@ -315,11 +313,20 @@ uint64_t memcached_behavior_get(memcached_st *ptr, /* REFACTOR */ /* We just try the first host, and if it is down we return zero */ if ((memcached_connect(instance)) != MEMCACHED_SUCCESS) - return 0; + { + return EXIT_SUCCESS; + } - if (getsockopt(instance->fd, SOL_SOCKET, - SO_SNDBUF, &sock_size, &sock_length)) - return 0; /* Zero means error */ + if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS) + { + return EXIT_SUCCESS; + } + + if (getsockopt(instance->fd, SOL_SOCKET, SO_SNDBUF, &sock_size, &sock_length) < 0) + { + ptr->cached_errno= errno; + return EXIT_SUCCESS; /* Zero means error */ + } } return (uint64_t) sock_size; @@ -342,11 +349,20 @@ uint64_t memcached_behavior_get(memcached_st *ptr, { /* We just try the first host, and if it is down we return zero */ if ((memcached_connect(instance)) != MEMCACHED_SUCCESS) - return 0; + { + return EXIT_SUCCESS; + } - if (getsockopt(instance->fd, SOL_SOCKET, - SO_RCVBUF, &sock_size, &sock_length)) - return 0; /* Zero means error */ + if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS) + { + return EXIT_SUCCESS; + } + + if (getsockopt(instance->fd, SOL_SOCKET, SO_RCVBUF, &sock_size, &sock_length) < 0) + { + ptr->cached_errno= errno; + return EXIT_SUCCESS; /* Zero means error */ + } } @@ -369,7 +385,7 @@ uint64_t memcached_behavior_get(memcached_st *ptr, case MEMCACHED_BEHAVIOR_MAX: default: WATCHPOINT_ASSERT(0); /* Programming mistake if it gets this far */ - return 0; + return EXIT_SUCCESS; } /* NOTREACHED */