libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit d7f5dece99015b3d624ee25585dfa028c079bea2
parent 9eebca21c09e278cb2a48c6dbb9beec35800d647
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue, 18 Oct 2016 21:06:22 +0300

MHD_response_execute_upgrade_(): improved handling of buffer sizes

Diffstat:
Msrc/microhttpd/response.c | 9++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -821,7 +821,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, urh->mhd.celi = MHD_EPOLL_STATE_UNREADY; pool = connection->pool; avail = MHD_pool_get_free (pool); - if (avail < 8) + if (avail < RESERVE_EBUF_SIZE) { /* connection's pool is totally at the limit, use our 'emergency' buffer of #RESERVE_EBUF_SIZE bytes. */ @@ -839,11 +839,10 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, MHD_NO); } /* use half the buffer for inbound, half for outbound */ - avail /= 2; - urh->in_buffer_size = avail; - urh->out_buffer_size = avail; + urh->in_buffer_size = avail / 2; + urh->out_buffer_size = avail - urh->in_buffer_size; urh->in_buffer = buf; - urh->out_buffer = &buf[avail]; + urh->out_buffer = &buf[urh->in_buffer_size]; /* hand over internal socket to application */ response->upgrade_handler (response->upgrade_handler_cls, connection,