emikulic / darkhttpd

When you need a web server in a hurry.
https://unix4lyfe.org/darkhttpd/
ISC License
1.03k stars 83 forks source link

Fix high CPU usage when timeout is disabled #8

Closed tdryer closed 3 years ago

tdryer commented 3 years ago

When darkhttpd is running with --timeout 0 (timeout disabled), and any connection is idle, it will use 100% of the CPU. This happens because select returns immediately when its timeout is zero, causing the main httpd_poll loop to spin.

Fix this by adding a check to httpd_poll making select always receive a NULL timeout when timeout_secs is zero.

emikulic commented 3 years ago

Nice catch, thanks!