Skip to content

Commit

Permalink
fix: send_reponse err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bushidocodes committed Dec 9, 2021
1 parent 569fdd3 commit acff356
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion runtime/include/client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions runtime/include/current_sandbox_send_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit acff356

Please sign in to comment.