chore: add client debug logging

main
Sean McBride 4 years ago
parent a54a72724b
commit c6dacb99ac

@ -70,7 +70,10 @@ sandbox_receive_and_parse_client_request(struct sandbox *sandbox)
0); 0);
/* Unexpected client shutdown.. or is this just EOF */ /* Unexpected client shutdown.. or is this just EOF */
if (length_read == 0 && !sandbox->http_request.message_end) goto err; if (length_read == 0 && !sandbox->http_request.message_end) {
debuglog("Client Shutdown Socket\n");
goto err;
}
if (length_read < 0) { if (length_read < 0) {
if (errno == EAGAIN) { if (errno == EAGAIN) {
@ -380,18 +383,21 @@ err:
assert(sandbox->state == SANDBOX_RUNNING); assert(sandbox->state == SANDBOX_RUNNING);
/* Send a 400 error back to the client */ /* Send a 400 error back to the client */
rc = 0;
int sent = 0; int sent = 0;
int to_send = strlen(HTTP_RESPONSE_400_BAD_REQUEST); int to_send = strlen(HTTP_RESPONSE_400_BAD_REQUEST);
while (sent < to_send) { while (sent < to_send) {
rc = write(sandbox->client_socket_descriptor, &HTTP_RESPONSE_400_BAD_REQUEST[sent], to_send - sent); rc = write(sandbox->client_socket_descriptor, &HTTP_RESPONSE_400_BAD_REQUEST[sent], to_send - sent);
if (rc < 0) { if (rc < 0) {
if (errno == EAGAIN) if (errno == EAGAIN) {
debuglog("Unexpectedly blocking on write of 4XX error");
worker_thread_block_current_sandbox(); worker_thread_block_current_sandbox();
else { continue;
}
debuglog("Failed to send 400: %s", strerror(errno)); debuglog("Failed to send 400: %s", strerror(errno));
break; break;
} }
}
sent += rc; sent += rc;
} }

Loading…
Cancel
Save