better fix for 5a5d9fd0.

Don't let net_recv_flush() do things as long as the HTTP layer
owns the buffer. When we have sent a response kick the read end
back into gear ourselves by calling net_recv_flush().
This commit is contained in:
Joris Vink 2018-07-18 16:10:41 +02:00
parent 086e2e3d5e
commit 916ce222b4
2 changed files with 7 additions and 3 deletions

View File

@ -713,8 +713,7 @@ http_header_recv(struct netbuf *nb)
/* take full ownership of the buffer. */
req->headers = nb->buf;
nb->buf = NULL;
nb->s_off = 0;
nb->buf = kore_malloc(nb->m_len);
nb->m_len = 0;
for (i = 1; i < h; i++) {
if (i == skip)
@ -1882,8 +1881,10 @@ http_response_normal(struct http_request *req, struct connection *c,
if (d != NULL && req != NULL && req->method != HTTP_METHOD_HEAD)
net_send_queue(c, d, len);
if (!(c->flags & CONN_CLOSE_EMPTY))
if (!(c->flags & CONN_CLOSE_EMPTY)) {
net_recv_reset(c, http_header_max, http_header_recv);
(void)net_recv_flush(c);
}
if (req != NULL)
req->content_length = len;

View File

@ -279,6 +279,9 @@ net_recv_flush(struct connection *c)
return (KORE_RESULT_OK);
while (c->flags & CONN_READ_POSSIBLE) {
if (c->rnb->buf == NULL)
return (KORE_RESULT_OK);
if (!c->read(c, &r))
return (KORE_RESULT_ERROR);
if (!(c->flags & CONN_READ_POSSIBLE))