Skip to content

Commit

Permalink
Fix binary protocol pipelining: always use the actual body length (#16)
Browse files Browse the repository at this point in the history
even when not saving the value.
  • Loading branch information
jplevyak2 authored and ushachar committed Mar 13, 2017
1 parent 98b9d96 commit 6bd7228
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,17 +812,16 @@ int memcache_binary_protocol::parse_response(void)
m_response_hdr.message.header.response.keylen);
assert((unsigned int) ret == 0);

int actual_body_len = m_response_hdr.message.header.response.bodylen -
m_response_hdr.message.header.response.extlen -
m_response_hdr.message.header.response.keylen;
if (m_keep_value) {
int actual_body_len = m_response_hdr.message.header.response.bodylen -
m_response_hdr.message.header.response.extlen -
m_response_hdr.message.header.response.keylen;
char *value = (char *) malloc(actual_body_len);
assert(value != NULL);

ret = evbuffer_remove(m_read_buf, value, actual_body_len);
m_last_response.set_value(value, actual_body_len);
} else {
int ret = evbuffer_drain(m_read_buf, m_response_hdr.message.header.response.bodylen);
int ret = evbuffer_drain(m_read_buf, actual_body_len);
assert((unsigned int) ret == 0);
}

Expand Down

0 comments on commit 6bd7228

Please sign in to comment.