From: Michael Wallner Date: Wed, 15 Sep 2021 14:30:03 +0000 (+0200) Subject: libmemcached: recent meta protocol fixes X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=28153bf5c12d2baa134f7ad4f7d948df04f8590e;p=awesomized%2Flibmemcached libmemcached: recent meta protocol fixes --- diff --git a/src/libmemcached/response.cc b/src/libmemcached/response.cc index fe01e388..9231caaf 100644 --- a/src/libmemcached/response.cc +++ b/src/libmemcached/response.cc @@ -418,6 +418,13 @@ static memcached_return_t textual_read_one_response(memcached_instance_st *insta } } break; + case 'H': + // HD + if (buffer[1] == 'D') { + return MEMCACHED_SUCCESS; + } + break; + case 'O': { // OK if (buffer[1] == 'K') { diff --git a/src/libmemcached/storage.cc b/src/libmemcached/storage.cc index 3d82edf5..0b96fbf3 100644 --- a/src/libmemcached/storage.cc +++ b/src/libmemcached/storage.cc @@ -183,7 +183,7 @@ memcached_send_meta(memcached_st *ptr, memcached_instance_st *instance, time_t expiration, uint32_t flags, uint64_t cas, bool flush, memcached_storage_action_t verb) { static const char modes[] = "SREPAS"; - char fl_buf[32] = " F", cs_buf[32] = " C", ex_buf[32] = " T", sz_buf[32] = " S"; + char fl_buf[32] = " F", cs_buf[32] = " C", ex_buf[32] = " T", sz_buf[32] = " "; size_t io_num = 0, fl_len = strlen(fl_buf), cs_len = strlen(cs_buf), ex_len = strlen(ex_buf), sz_len = strlen(sz_buf); libmemcached_io_vector_st io_vec[16] = {}; @@ -192,6 +192,9 @@ memcached_send_meta(memcached_st *ptr, memcached_instance_st *instance, memcached_array_size(ptr->_namespace)}; io_vec[io_num++] = {key, key_len}; + sz_len += snprintf(sz_buf + sz_len, sizeof(sz_buf) - sz_len, "%" PRIu64, (uint64_t) val_len); + io_vec[io_num++] = {sz_buf, sz_len}; + if (verb != SET_OP) { io_vec[io_num++] = {memcached_literal_param(" M")}; io_vec[io_num++] = {&modes[verb], 1}; @@ -213,8 +216,6 @@ memcached_send_meta(memcached_st *ptr, memcached_instance_st *instance, } /* we have to send a data block even if it's empty, else memcached errors out with ITEM TOO BIG */ - sz_len += snprintf(sz_buf + sz_len, sizeof(sz_buf) - sz_len, "%" PRIu64, (uint64_t) val_len); - io_vec[io_num++] = {sz_buf, sz_len}; io_vec[io_num++] = {memcached_literal_param("\r\n")}; io_vec[io_num++] = {val, val_len}; io_vec[io_num++] = {memcached_literal_param("\r\n")};