From acff35683a1c8355a7e541f74d0b79d299aab717 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 9 Dec 2021 16:47:23 -0500 Subject: [PATCH] fix: send_reponse err handling --- runtime/include/client_socket.h | 2 +- runtime/include/current_sandbox_send_response.h | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/runtime/include/client_socket.h b/runtime/include/client_socket.h index f801f5e8a..3717c10db 100644 --- a/runtime/include/client_socket.h +++ b/runtime/include/client_socket.h @@ -40,7 +40,7 @@ typedef void (*void_cb)(void); * @param client_socket - the client we are rejecting * @param buffer - buffer to write to socket * @param on_eagain - cb to execute when client socket returns EAGAIN. If NULL, error out - * @returns 0 + * @returns 0 on success, -1 on error. */ static inline int client_socket_send(int client_socket, const char *buffer, size_t buffer_len, void_cb on_eagain) diff --git a/runtime/include/current_sandbox_send_response.h b/runtime/include/current_sandbox_send_response.h index d61081c40..ddccc8f62 100644 --- a/runtime/include/current_sandbox_send_response.h +++ b/runtime/include/current_sandbox_send_response.h @@ -40,9 +40,12 @@ current_sandbox_send_response() sandbox->total_time = end_time - sandbox->timestamp_of.request_arrival; /* Send HTTP Response Header and Body */ - http_header_200_write(sandbox->client_socket_descriptor, module_content_type, response_body_size); - client_socket_send(sandbox->client_socket_descriptor, (const char *)response->buffer, response_body_size, - current_sandbox_sleep); + rc = http_header_200_write(sandbox->client_socket_descriptor, module_content_type, response_body_size); + if (rc < 0) goto err; + + rc = client_socket_send(sandbox->client_socket_descriptor, (const char *)response->buffer, response_body_size, + current_sandbox_sleep); + if (rc < 0) goto err; http_total_increment_2xx(); rc = 0;