summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortiptorrent development team <tiptorrent@soleta.eu>2021-09-13 12:59:48 +0200
committertiptorrent development team <tiptorrent@soleta.eu>2021-09-29 15:48:20 +0200
commit1e0b3880f945bb8c3a37997f32ea1c585a79491e (patch)
tree6fa61165a1042803c514e6e5b684f6c7bdb6fa6c
parent21aa4a9315921413743e2aa006f6e1102ff71c63 (diff)
fix client timeout
as described by man(3) ev, to make it work with ev_timer_again().
-rw-r--r--src/core.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core.c b/src/core.c
index 530c86a..0da582c 100644
--- a/src/core.c
+++ b/src/core.c
@@ -325,14 +325,15 @@ static void tip_client_timer_cb(struct ev_loop *loop, ev_timer *timer, int event
}
/* Shut down connection if there is no data after 15 seconds. */
-#define TIP_CLIENT_TIMEOUT 15
+#define TIP_CLIENT_TIMEOUT 15.
static void tip_client_start(struct tip_client *cli)
{
cli->state = TIP_CLIENT_RECEIVING_HEADER;
ev_io_start(tip_main_loop, &cli->io);
- ev_timer_init(&cli->timer, tip_client_timer_cb, TIP_CLIENT_TIMEOUT, 0.);
- ev_timer_start(tip_main_loop, &cli->timer);
+ ev_init(&cli->timer, tip_client_timer_cb);
+ cli->timer.repeat = TIP_CLIENT_TIMEOUT;
+ ev_timer_again(tip_main_loop, &cli->timer);
}
void tip_client_pending(struct tip_client *cli)
@@ -357,7 +358,7 @@ static void tip_client_activate_pending(void)
}
ev_io_set(&cli->io, tip_client_socket(cli), EV_READ | EV_WRITE);
ev_io_start(tip_main_loop, &cli->io);
- ev_timer_start(tip_main_loop, &cli->timer);
+ ev_timer_again(tip_main_loop, &cli->timer);
cli->state = TIP_CLIENT_PROCESSING_REQUEST_2;
break;
}