From: Brian Aker Date: Mon, 30 Jan 2012 09:27:30 +0000 (-0800) Subject: Make version handle messages by priority. X-Git-Tag: 1.0.5~75 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=1b54cf9cafe52214b743eda46d4450668b757c03;p=awesomized%2Flibmemcached Make version handle messages by priority. --- diff --git a/libmemcached/version.cc b/libmemcached/version.cc index 7fc85fd4..9ba09b0d 100644 --- a/libmemcached/version.cc +++ b/libmemcached/version.cc @@ -48,6 +48,7 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr) { memcached_literal_param("version\r\n") }, }; + uint32_t success= 0; bool errors_happened= false; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { @@ -64,13 +65,23 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr) { errors_happened= true; (void)memcached_set_error(*instance, rrc, MEMCACHED_AT); - instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; + continue; } - else if (memcached_failed(rrc= memcached_response(instance, NULL))) + success++; + } + + if (success) + { + // Collect the returned items + memcached_server_write_instance_st instance; + while ((instance= memcached_io_get_readable_server(ptr))) { - errors_happened= true; - memcached_set_error(*instance, rrc, MEMCACHED_AT); - instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; + memcached_return_t rrc= memcached_response(instance, NULL); + if (memcached_failed(rrc)) + { + memcached_io_reset(instance); + errors_happened= true; + } } }