From: Brian Aker Date: Mon, 21 May 2012 05:08:39 +0000 (-0400) Subject: Simplify purge return value. X-Git-Tag: 1.0.8~2^2~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a28d1ecc082d9d08c4f59f071de9a43fbd08aee3;p=awesomized%2Flibmemcached Simplify purge return value. --- diff --git a/libmemcached/common.h b/libmemcached/common.h index f7559376..2fe6b0f8 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -169,8 +169,7 @@ memcached_return_t run_distribution(memcached_st *ptr); #define memcached_server_response_decrement(A) (A)->cursor_active-- #define memcached_server_response_reset(A) (A)->cursor_active=0 -LIBMEMCACHED_LOCAL -memcached_return_t memcached_purge(memcached_server_write_instance_st ptr); +bool memcached_purge(memcached_server_write_instance_st ptr); #ifdef __cplusplus } diff --git a/libmemcached/io.cc b/libmemcached/io.cc index 06aa57c1..d0e6aaf6 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -178,7 +178,7 @@ static memcached_return_t io_wait(memcached_server_write_instance_st ptr, */ if (read_or_write == MEM_WRITE) { - if (memcached_fatal(memcached_purge(ptr))) + if (memcached_purge(ptr) == false) { return MEMCACHED_FAILURE; } @@ -276,9 +276,8 @@ static bool io_flush(memcached_server_write_instance_st ptr, */ { WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); - memcached_return_t rc= memcached_purge(ptr); - if (rc != MEMCACHED_SUCCESS and rc != MEMCACHED_STORED) + if (memcached_purge(ptr) == false) { return false; } diff --git a/libmemcached/purge.cc b/libmemcached/purge.cc index 6142e5fb..38e4552a 100644 --- a/libmemcached/purge.cc +++ b/libmemcached/purge.cc @@ -40,9 +40,8 @@ #include -memcached_return_t memcached_purge(memcached_server_write_instance_st ptr) +bool memcached_purge(memcached_server_write_instance_st ptr) { - memcached_return_t ret= MEMCACHED_SUCCESS; memcached_st *root= (memcached_st *)ptr->root; if (memcached_is_purging(ptr->root) || /* already purging */ @@ -51,7 +50,7 @@ memcached_return_t memcached_purge(memcached_server_write_instance_st ptr) (ptr->io_bytes_sent >= ptr->root->io_bytes_watermark && memcached_server_response_count(ptr) < 2)) { - return MEMCACHED_SUCCESS; + return true; } /* @@ -69,10 +68,12 @@ memcached_return_t memcached_purge(memcached_server_write_instance_st ptr) { memcached_set_purging(root, true); - return memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); + memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); + return false; } WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); + bool is_successful= true; uint32_t no_msg= memcached_server_response_count(ptr) - 1; if (no_msg > 0) { @@ -103,10 +104,7 @@ memcached_return_t memcached_purge(memcached_server_write_instance_st ptr) { WATCHPOINT_ERROR(rc); memcached_io_reset(ptr); - ret= rc; -#if 0 - ret= memcached_set_error(*ptr, rc, MEMCACHED_AT); -#endif + is_successful= false; } if (ptr->root->callbacks != NULL) @@ -130,5 +128,5 @@ memcached_return_t memcached_purge(memcached_server_write_instance_st ptr) } memcached_set_purging(root, false); - return ret; + return is_successful; }