Skip to content

Commit

Permalink
libmemcached: recent meta protocol fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
m6w6 committed Feb 2, 2022
1 parent 5a6a6ab commit 28153bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/libmemcached/response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
7 changes: 4 additions & 3 deletions src/libmemcached/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {};

Expand All @@ -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};
Expand All @@ -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")};
Expand Down

0 comments on commit 28153bf

Please sign in to comment.