Skip to content
Snippets Groups Projects
Commit 0d675fd5 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

iproto: fix the bug with ever growing output buffer

* don't recycle input buffer if this leads to growth of the output
buffer
parent 30d9171a
No related branches found
No related tags found
No related merge requests found
...@@ -442,8 +442,21 @@ iproto_session_input_iobuf(struct iproto_session *session) ...@@ -442,8 +442,21 @@ iproto_session_input_iobuf(struct iproto_session *session)
if (ibuf_unused(&oldbuf->in) >= to_read) if (ibuf_unused(&oldbuf->in) >= to_read)
return oldbuf; return oldbuf;
/** All requests are processed, reuse the buffer. */ /**
if (ibuf_size(&oldbuf->in) == session->parse_size) { * Reuse the buffer if:
* - all requests are processed (in only has unparsed
* content, and out is empty, so we will not bloat
* output by reusing input
* - we received a large packet, so we need to
* extend input buffer size to store a single large
* packet. In this case we need to realloc the input
* buffer, simply falling through to the subsequent
* branches will not make the buffer larger.
*/
if (ibuf_size(&oldbuf->in) == session->parse_size &&
(ibuf_pos(&oldbuf->in) == session->parse_size ||
obuf_size(&oldbuf->out) == 0)) {
ibuf_reserve(&oldbuf->in, to_read); ibuf_reserve(&oldbuf->in, to_read);
return oldbuf; return oldbuf;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment