From: Michael Wallner Date: Mon, 27 Jan 2020 13:07:16 +0000 (+0100) Subject: attempt to fix #12, #49 and #65 X-Git-Tag: pre_cmake~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=9973d386ac8476cd09cc4d9cf7bd2234a42740c7;hp=4032d474f0f6fb97d2607e8b5ea5c21f1588cb55;p=awesomized%2Flibmemcached attempt to fix #12, #49 and #65 use memcached_io_reset() at the right places (i.e. memcached_vdo()) --- diff --git a/libmemcached/delete.cc b/libmemcached/delete.cc index 55a8b4ca..9575a957 100644 --- a/libmemcached/delete.cc +++ b/libmemcached/delete.cc @@ -98,12 +98,7 @@ static inline memcached_return_t binary_delete(memcached_instance_st* instance, { key, key_length } }; - memcached_return_t rc; - if (memcached_fatal(rc= memcached_vdo(instance, vector, 4, should_flush))) - { - assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS); - memcached_io_reset(instance); - } + memcached_return_t rc= memcached_vdo(instance, vector, 4, should_flush); if (memcached_has_replicas(instance)) { @@ -120,12 +115,7 @@ static inline memcached_return_t binary_delete(memcached_instance_st* instance, memcached_instance_st* replica= memcached_instance_fetch(instance->root, server_key); - if (memcached_fatal(memcached_vdo(replica, vector, 4, should_flush))) - { - assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS); - memcached_io_reset(replica); - } - else + if (memcached_success(memcached_vdo(replica, vector, 4, should_flush))) { memcached_server_response_decrement(replica); } diff --git a/libmemcached/do.cc b/libmemcached/do.cc index daf1a115..59f9d5a3 100644 --- a/libmemcached/do.cc +++ b/libmemcached/do.cc @@ -85,26 +85,23 @@ memcached_return_t memcached_vdo(memcached_instance_st* instance, ** before they start writing, if there is any data in buffer, clear it out, ** otherwise we might get a partial write. **/ + bool sent_success; if (memcached_is_udp(instance->root)) { - return _vdo_udp(instance, vector, count); + sent_success= memcached_success(rc= _vdo_udp(instance, vector, count)); + } else { + sent_success= memcached_io_writev(instance, vector, count, with_flush); } - - bool sent_success= memcached_io_writev(instance, vector, count, with_flush); if (sent_success == false) { - //assert(memcached_last_error(instance->root) == MEMCACHED_SUCCESS); - if (memcached_last_error(instance->root) == MEMCACHED_SUCCESS) - { - //assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS); - return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); - } - else + rc= memcached_last_error(instance->root); + if (rc == MEMCACHED_SUCCESS) { - rc= memcached_last_error(instance->root); + memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); } + memcached_io_reset(instance); } - else if (memcached_is_replying(instance->root)) + else if (memcached_is_replying(instance->root) && !memcached_is_udp(instance->root)) { memcached_server_response_increment(instance); } diff --git a/libmemcached/dump.cc b/libmemcached/dump.cc index f74f3ed1..4fcf7de2 100644 --- a/libmemcached/dump.cc +++ b/libmemcached/dump.cc @@ -71,11 +71,7 @@ static memcached_return_t ascii_dump(Memcached *memc, memcached_dump_fn *callbac memcached_instance_st* instance= memcached_instance_fetch(memc, server_key); memcached_return_t vdo_rc; - if (memcached_success((vdo_rc= memcached_vdo(instance, vector, 3, true)))) - { - // We have sent the message to the server successfully - } - else + if (memcached_failed((vdo_rc= memcached_vdo(instance, vector, 3, true)))) { return vdo_rc; } diff --git a/libmemcached/exist.cc b/libmemcached/exist.cc index 3afb42d4..5cb99e60 100644 --- a/libmemcached/exist.cc +++ b/libmemcached/exist.cc @@ -155,10 +155,5 @@ memcached_return_t memcached_exist_by_key(memcached_st *shell, rc= ascii_exist(memc, instance, key, key_length); } - if (memcached_fatal(rc)) - { - memcached_io_reset(instance); - } - return rc; } diff --git a/libmemcached/flush.cc b/libmemcached/flush.cc index cbb66bfe..9702771f 100644 --- a/libmemcached/flush.cc +++ b/libmemcached/flush.cc @@ -77,7 +77,6 @@ static memcached_return_t memcached_flush_binary(Memcached *ptr, { memcached_set_error(*instance, rrc, MEMCACHED_AT); } - memcached_io_reset(instance); rc= MEMCACHED_SOME_ERRORS; } } diff --git a/libmemcached/purge.cc b/libmemcached/purge.cc index 4646708e..4dbe24d0 100644 --- a/libmemcached/purge.cc +++ b/libmemcached/purge.cc @@ -105,6 +105,7 @@ bool memcached_purge(memcached_instance_st* ptr) */ if (memcached_io_write(ptr) == false) { + memcached_io_reset(ptr); memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); return false; } @@ -138,7 +139,6 @@ bool memcached_purge(memcached_instance_st* ptr) if (rc== MEMCACHED_PROTOCOL_ERROR or rc == MEMCACHED_UNKNOWN_READ_FAILURE or rc == MEMCACHED_READ_FAILURE) { WATCHPOINT_ERROR(rc); - memcached_io_reset(ptr); is_successful= false; } diff --git a/libmemcached/stats.cc b/libmemcached/stats.cc index 180b0d98..9e6083e9 100644 --- a/libmemcached/stats.cc +++ b/libmemcached/stats.cc @@ -484,6 +484,7 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; protocol_binary_request_stats request= {}; // = {.bytes= {0}}; + memcached_return_t rc; initialize_binary_request(instance, request.message.header); @@ -501,10 +502,9 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, { args, args_length } }; - if (memcached_vdo(instance, vector, 2, true) != MEMCACHED_SUCCESS) + if (memcached_failed(rc = memcached_vdo(instance, vector, 2, true))) { - memcached_io_reset(instance); - return MEMCACHED_WRITE_FAILURE; + return rc; } } else @@ -514,17 +514,16 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, { request.bytes, sizeof(request.bytes) } }; - if (memcached_vdo(instance, vector, 1, true) != MEMCACHED_SUCCESS) + if (memcached_failed(rc = memcached_vdo(instance, vector, 1, true))) { - memcached_io_reset(instance); - return MEMCACHED_WRITE_FAILURE; + return rc; } } memcached_server_response_decrement(instance); while (1) { - memcached_return_t rc= memcached_response(instance, buffer, sizeof(buffer), NULL); + rc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (rc == MEMCACHED_END) { @@ -533,7 +532,6 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, if (rc != MEMCACHED_SUCCESS) { - memcached_io_reset(instance); return rc; } diff --git a/libmemcached/storage.cc b/libmemcached/storage.cc index 46ae15a9..079fba1d 100644 --- a/libmemcached/storage.cc +++ b/libmemcached/storage.cc @@ -192,15 +192,6 @@ static memcached_return_t memcached_send_binary(Memcached *ptr, memcached_return_t rc; if ((rc= memcached_vdo(server, vector, 5, flush)) != MEMCACHED_SUCCESS) { - memcached_io_reset(server); - -#if 0 - if (memcached_has_error(ptr)) - { - memcached_set_error(*server, rc, MEMCACHED_AT); - } -#endif - assert(memcached_last_error(server->root) != MEMCACHED_SUCCESS); return memcached_last_error(server->root); } @@ -220,11 +211,7 @@ static memcached_return_t memcached_send_binary(Memcached *ptr, memcached_instance_st* instance= memcached_instance_fetch(ptr, server_key); - if (memcached_vdo(instance, vector, 5, false) != MEMCACHED_SUCCESS) - { - memcached_io_reset(instance); - } - else + if (memcached_success(memcached_vdo(instance, vector, 5, false))) { memcached_server_response_decrement(instance); } @@ -335,11 +322,6 @@ static memcached_return_t memcached_send_ascii(Memcached *ptr, } } - if (rc == MEMCACHED_WRITE_FAILURE) - { - memcached_io_reset(instance); - } - assert(memcached_failed(rc)); #if 0 if (memcached_has_error(ptr) == false) diff --git a/libmemcached/touch.cc b/libmemcached/touch.cc index 91d0825f..a638bf9f 100644 --- a/libmemcached/touch.cc +++ b/libmemcached/touch.cc @@ -63,7 +63,6 @@ static memcached_return_t ascii_touch(memcached_instance_st* instance, memcached_return_t rc; if (memcached_failed(rc= memcached_vdo(instance, vector, 6, true))) { - memcached_io_reset(instance); return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); } @@ -96,7 +95,6 @@ static memcached_return_t binary_touch(memcached_instance_st* instance, memcached_return_t rc; if (memcached_failed(rc= memcached_vdo(instance, vector, 4, true))) { - memcached_io_reset(instance); return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); } diff --git a/libmemcached/version.cc b/libmemcached/version.cc index 5f074912..e779a769 100644 --- a/libmemcached/version.cc +++ b/libmemcached/version.cc @@ -80,7 +80,6 @@ static inline memcached_return_t memcached_version_textual(Memcached *memc) memcached_return_t rrc= memcached_response(instance, NULL); if (memcached_failed(rrc)) { - memcached_io_reset(instance); errors_happened= true; } } @@ -117,7 +116,6 @@ static inline memcached_return_t memcached_version_binary(Memcached *memc) memcached_return_t rrc= memcached_vdo(instance, vector, 1, true); if (memcached_failed(rrc)) { - memcached_io_reset(instance); errors_happened= true; continue; } @@ -136,7 +134,6 @@ static inline memcached_return_t memcached_version_binary(Memcached *memc) memcached_return_t rrc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (memcached_failed(rrc)) { - memcached_io_reset(instance); errors_happened= true; } }