kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 8fcf4762f4de4bc6aacd7d2d2780c7c6bda03d74
parent 4503b4756b3156468cbc0250bf50964e2a04b29c
Author: Joris Vink <joris@coders.se>
Date:   Sat, 13 Feb 2016 15:41:37 +0100

Improve http_body_recv().

- If we fail to write to our temporary file error instead of fatal.
- Return KORE_RESULT_ERROR on other errors as well.

Diffstat:
src/http.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/http.c b/src/http.c @@ -1314,14 +1314,17 @@ http_body_recv(struct netbuf *nb) if (req->http_body_fd != -1) { ret = write(req->http_body_fd, nb->buf, nb->s_off); - if (ret == -1 || (size_t)ret != nb->s_off) - fatal("failed to write"); + if (ret == -1 || (size_t)ret != nb->s_off) { + req->flags |= HTTP_REQUEST_DELETE; + http_error_response(req->owner, 500); + return (KORE_RESULT_ERROR); + } } else if (req->http_body != NULL) { kore_buf_append(req->http_body, nb->buf, nb->s_off); } else { req->flags |= HTTP_REQUEST_DELETE; http_error_response(req->owner, 500); - return (KORE_RESULT_OK); + return (KORE_RESULT_ERROR); } req->content_length -= nb->s_off; @@ -1335,7 +1338,7 @@ http_body_recv(struct netbuf *nb) if (!http_body_rewind(req)) { req->flags |= HTTP_REQUEST_DELETE; http_error_response(req->owner, 500); - return (KORE_RESULT_OK); + return (KORE_RESULT_ERROR); } net_recv_reset(nb->owner, http_header_max, http_header_recv); } else {