commit 916ce222b4d027447e8246cf4d4fb7d930509516
parent 086e2e3d5ebfa8c09d076d9530d903a5047adcc0
Author: Joris Vink <joris@coders.se>
Date: Wed, 18 Jul 2018 16:10:41 +0200
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().
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/http.c b/src/http.c
@@ -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;
diff --git a/src/net.c b/src/net.c
@@ -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))