X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fio.cc;h=8796d5034b8a2dd82927443662e32918579dab58;hb=7be9389170df33175d87c12f3b6cf48fdf7d0934;hp=cb8ed5c23199eac47b5665ca6733384216b4ffbb;hpb=d9db3f534bc38ea22e83e5529ff93aea4150ab19;p=awesomized%2Flibmemcached diff --git a/libmemcached/io.cc b/libmemcached/io.cc index cb8ed5c2..8796d503 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -99,7 +99,7 @@ static bool repack_input_buffer(memcached_instance_st* instance) case EWOULDBLOCK: #endif case EAGAIN: -#ifdef TARGET_OS_LINUX +#ifdef __linux case ERESTART: #endif break; // No IO is fine, we can just move on @@ -177,7 +177,7 @@ static bool process_input_buffer(memcached_instance_st* instance) } static memcached_return_t io_wait(memcached_instance_st* instance, - const memc_read_or_write read_or_write) + const short events) { /* ** We are going to block on write, but at least on Solaris we might block @@ -187,7 +187,7 @@ static memcached_return_t io_wait(memcached_instance_st* instance, ** The test is moved down in the purge function to avoid duplication of ** the test. */ - if (read_or_write == MEM_WRITE) + if (events & POLLOUT) { if (memcached_purge(instance) == false) { @@ -197,12 +197,11 @@ static memcached_return_t io_wait(memcached_instance_st* instance, struct pollfd fds; fds.fd= instance->fd; - fds.events= POLLIN; + fds.events= events; fds.revents= 0; - if (read_or_write == MEM_WRITE) /* write */ + if (fds.events & POLLOUT) /* write */ { - fds.events= POLLOUT; instance->io_wait_count.write++; } else @@ -265,7 +264,7 @@ static memcached_return_t io_wait(memcached_instance_st* instance, assert_msg(active_fd == -1 , "poll() returned an unexpected value"); switch (local_errno) { -#ifdef TARGET_OS_LINUX +#ifdef __linux case ERESTART: #endif case EINTR: @@ -371,7 +370,7 @@ static bool io_flush(memcached_instance_st* instance, continue; } - memcached_return_t rc= io_wait(instance, MEM_WRITE); + memcached_return_t rc= io_wait(instance, POLLOUT); if (memcached_success(rc)) { continue; @@ -409,7 +408,12 @@ static bool io_flush(memcached_instance_st* instance, memcached_return_t memcached_io_wait_for_write(memcached_instance_st* instance) { - return io_wait(instance, MEM_WRITE); + return io_wait(instance, POLLOUT); +} + +memcached_return_t memcached_io_wait_for_read(memcached_instance_st* instance) +{ + return io_wait(instance, POLLIN); } static memcached_return_t _io_fill(memcached_instance_st* instance) @@ -430,12 +434,12 @@ static memcached_return_t _io_fill(memcached_instance_st* instance) case EWOULDBLOCK: #endif case EAGAIN: -#ifdef TARGET_OS_LINUX +#ifdef __linux case ERESTART: #endif { memcached_return_t io_wait_ret; - if (memcached_success(io_wait_ret= io_wait(instance, MEM_READ))) + if (memcached_success(io_wait_ret= io_wait(instance, POLLIN))) { continue; } @@ -568,10 +572,10 @@ memcached_return_t memcached_io_slurp(memcached_instance_st* instance) case EWOULDBLOCK: #endif case EAGAIN: -#ifdef TARGET_OS_LINUX +#ifdef __linux case ERESTART: #endif - if (memcached_success(io_wait(instance, MEM_READ))) + if (memcached_success(io_wait(instance, POLLIN))) { continue; }