Skip to content

Commit 6bd7228

Browse files
jplevyak2ushachar
authored andcommitted
Fix binary protocol pipelining: always use the actual body length (#16)
even when not saving the value.
1 parent 98b9d96 commit 6bd7228

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

protocol.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,17 +812,16 @@ int memcache_binary_protocol::parse_response(void)
812812
m_response_hdr.message.header.response.keylen);
813813
assert((unsigned int) ret == 0);
814814

815+
int actual_body_len = m_response_hdr.message.header.response.bodylen -
816+
m_response_hdr.message.header.response.extlen -
817+
m_response_hdr.message.header.response.keylen;
815818
if (m_keep_value) {
816-
int actual_body_len = m_response_hdr.message.header.response.bodylen -
817-
m_response_hdr.message.header.response.extlen -
818-
m_response_hdr.message.header.response.keylen;
819819
char *value = (char *) malloc(actual_body_len);
820820
assert(value != NULL);
821-
822821
ret = evbuffer_remove(m_read_buf, value, actual_body_len);
823822
m_last_response.set_value(value, actual_body_len);
824823
} else {
825-
int ret = evbuffer_drain(m_read_buf, m_response_hdr.message.header.response.bodylen);
824+
int ret = evbuffer_drain(m_read_buf, actual_body_len);
826825
assert((unsigned int) ret == 0);
827826
}
828827

0 commit comments

Comments
 (0)