advance refcnt only if it was used

This commit is contained in:
KIU Shueng Chuan
2015-07-22 21:19:22 +08:00
parent c05a475bf7
commit 708353a1b9
3 changed files with 11 additions and 4 deletions

View File

@@ -63,11 +63,12 @@ int zmq::raw_decoder_t::decode (const uint8_t *data_, size_t size_,
int rc = in_progress.init ((unsigned char*)data_, size_,
shared_message_memory_allocator::call_dec_ref,
allocator.buffer(),
allocator.create_refcnt() );
allocator.provide_refcnt() );
// if the buffer serves as memory for a zero-copy message, release it
// and allocate a new buffer in get_buffer for the next decode
if (in_progress.is_zcmsg()) {
allocator.advance_refcnt();
allocator.release();
}