mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Fix high CPU usage when timeout is disabled (#8)
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.
This commit is contained in:
parent
667edacaa3
commit
59b30c5cbc
@ -2518,6 +2518,9 @@ static void httpd_poll(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -select- */
|
/* -select- */
|
||||||
|
if (timeout_secs == 0) {
|
||||||
|
bother_with_timeout = 0;
|
||||||
|
}
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf("select() with max_fd %d timeout %d\n",
|
printf("select() with max_fd %d timeout %d\n",
|
||||||
max_fd, bother_with_timeout ? (int)timeout.tv_sec : 0);
|
max_fd, bother_with_timeout ? (int)timeout.tv_sec : 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user