From 473a604470aa72c043242128a7cbe006999d9e19 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Thu, 15 Dec 2011 16:19:33 -0800 Subject: [PATCH] Fix OSX failure, and have memcached_do just use memcached_vdo --- libmemcached/auto.cc | 2 ++ libmemcached/do.cc | 40 +++++++------------------------- libmemcached/io.cc | 4 ++-- tests/libmemcached-1.0/parser.cc | 4 ++++ 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/libmemcached/auto.cc b/libmemcached/auto.cc index b2e4f534..507ae366 100644 --- a/libmemcached/auto.cc +++ b/libmemcached/auto.cc @@ -71,7 +71,9 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, memcached_return_t rc= memcached_do(instance, buffer, (size_t)send_length, true); if (no_reply or memcached_failed(rc)) + { return rc; + } rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); diff --git a/libmemcached/do.cc b/libmemcached/do.cc index c3cfab93..99dba559 100644 --- a/libmemcached/do.cc +++ b/libmemcached/do.cc @@ -11,46 +11,22 @@ #include -memcached_return_t memcached_do(memcached_server_write_instance_st ptr, const void *command, - size_t command_length, bool with_flush) +memcached_return_t memcached_do(memcached_server_write_instance_st ptr, + const void *command, + size_t command_length, + bool with_flush) { assert_msg(command_length, "Programming error, somehow a command had a length of zero"); assert_msg(command, "Programming error, somehow a command was NULL"); - memcached_return_t rc; - if (memcached_failed(rc= memcached_connect(ptr))) - { - WATCHPOINT_ASSERT(rc == memcached_last_error(ptr->root)); - WATCHPOINT_ERROR(rc); - return rc; - } - - /* - ** Since non buffering ops in UDP mode dont check to make sure they will fit - ** before they start writing, if there is any data in buffer, clear it out, - ** otherwise we might get a partial write. - **/ - if (memcached_is_udp(ptr->root) and with_flush and ptr->write_buffer_offset > UDP_DATAGRAM_HEADER_LENGTH) - { - memcached_io_write(ptr, NULL, 0, true); - } + libmemcached_io_vector_st vector[1]= { { command, command_length } }; - ssize_t sent_length= memcached_io_write(ptr, command, command_length, with_flush); - - if (sent_length == -1 or size_t(sent_length) != command_length) - { - rc= MEMCACHED_WRITE_FAILURE; - } - else if ((ptr->root->flags.no_reply) == 0) - { - memcached_server_response_increment(ptr); - } - - return rc; + return memcached_vdo(ptr, vector, 1, with_flush); } memcached_return_t memcached_vdo(memcached_server_write_instance_st ptr, - const struct libmemcached_io_vector_st *vector, size_t count, + const struct libmemcached_io_vector_st *vector, + size_t count, bool with_flush) { memcached_return_t rc; diff --git a/libmemcached/io.cc b/libmemcached/io.cc index 85e5ed42..22cd474c 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -354,11 +354,11 @@ static ssize_t io_flush(memcached_server_write_instance_st ptr, WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); if (with_flush) { - sent_length= send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT); + sent_length= ::send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT); } else { - sent_length= send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT|MSG_MORE); + sent_length= ::send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT|MSG_MORE); } if (sent_length == SOCKET_ERROR) diff --git a/tests/libmemcached-1.0/parser.cc b/tests/libmemcached-1.0/parser.cc index 32b0d9d8..03da195a 100644 --- a/tests/libmemcached-1.0/parser.cc +++ b/tests/libmemcached-1.0/parser.cc @@ -762,7 +762,11 @@ test_return_t regression_bug_71231153_poll(memcached_st *) char *value= memcached_get(memc, test_literal_param("test"), &value_len, NULL, &rc); test_false(value); test_zero(value_len); +#ifdef __APPLE__ + test_compare_got(MEMCACHED_CONNECTION_FAILURE, rc, memcached_last_error_message(memc)); +#else test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_last_error_message(memc)); +#endif memcached_free(memc); } -- 2.30.2