u413-284-si / webserv

This project is about setting up a http web server, providing a static website.
MIT License
0 stars 0 forks source link

core: call epoll with TIMEOUT value #14

Closed u413-284-si closed 2 months ago

u413-284-si commented 4 months ago

Calling epoll with a timeout prevents the server from waiting endlessly for a connection which may be broken or has faulty requests, such as a chunked body which is missing the zero-size chunk at the end. The server would be stuck in an endless loop otherwise, expecting to find this zero chunk to indicate the end of the body. Having a timeout will help to break out of the loop and take appropriate actions e.g. closing the connection.

EDIT: Alternatively implement a check in the parseChunkedBody() loop for current body length vs. max. allowed body length (defined by config file or default value). Break out of loop if check condition reached.