summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-09-09 11:59:40 +0100
committerrofl0r <rofl0r@users.noreply.github.com>2020-09-09 11:59:40 +0100
commitb4e3f1a896989d1e5190e114b5bc05cd613ef646 (patch)
treee2c8d1a0a4c1b43ddf9ea5afb870bb93c17871a3 /src
parent78cc5b72b18a3c0d196126bfbc5d3b6473386da9 (diff)
fix negative timeout resulting in select() EINVAL
Diffstat (limited to 'src')
-rw-r--r--src/reqs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/reqs.c b/src/reqs.c
index 370b375..074b416 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1177,13 +1177,18 @@ static void relay_connection (struct conn_s *connptr)
last_access = time (NULL);
for (;;) {
- FD_ZERO (&rset);
- FD_ZERO (&wset);
-
tv.tv_sec =
config->idletimeout - difftime (time (NULL), last_access);
tv.tv_usec = 0;
+ if (tv.tv_sec < 0) {
+ tdiff = config->idletimeout + 1;
+ goto e_timedout;
+ }
+
+ FD_ZERO (&rset);
+ FD_ZERO (&wset);
+
if (buffer_size (connptr->sbuffer) > 0)
FD_SET (connptr->client_fd, &wset);
if (buffer_size (connptr->cbuffer) > 0)
@@ -1198,6 +1203,7 @@ static void relay_connection (struct conn_s *connptr)
if (ret == 0) {
tdiff = difftime (time (NULL), last_access);
if (tdiff > config->idletimeout) {
+ e_timedout:;
log_message (LOG_INFO,
"Idle Timeout (after select) as %g > %u.",
tdiff, config->idletimeout);