feat: small changes

c-web-server
Jef Roosens 2023-05-27 18:47:07 +02:00
parent 4d436aa8aa
commit 90ff55d977
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 6 additions and 18 deletions

View File

@ -68,29 +68,15 @@ void event_loop_conn_io_req(event_loop *el, event_loop_conn *conn) {
return; return;
} }
// Any other negative error message means the read errored out // Any other negative error message means the read errored out. If res is 0,
if (res < 0) { // we've reached the end of the input which (usually) means the remote peer
// has closed the connection. Either way, we close the connection.
if (res <= 0) {
conn->state = event_loop_conn_state_end; conn->state = event_loop_conn_state_end;
return; return;
} }
// Output of 0 and no error means we've reached the end of the input. We run
// try_one_request one more time and close the connection if this doesn't
// change the result.
if (res == 0) {
conn->state = event_loop_conn_state_end;
return;
}
// We switch to processing mode if we've reached the end of the data stream,
// or if the read buffer is filled
/* if (res == 0 || c->rbuf_size == MAX_MSG_SIZE) { */
/* c->state = STATE_PROCESS; */
/* return false; */
/* } */
conn->rbuf_size += (size_t)res; conn->rbuf_size += (size_t)res;
// This loop allows processing multiple requests from a single read buffer // This loop allows processing multiple requests from a single read buffer

View File

@ -37,6 +37,8 @@ bool http_loop_handle_request(event_loop_conn *conn) {
return false; return false;
} }
conn->rbuf_read += res;
// If the routing fails, we exit the handler // If the routing fails, we exit the handler
if (!http_loop_route_request(conn)) { if (!http_loop_route_request(conn)) {
return false; return false;