From 1e0b3880f945bb8c3a37997f32ea1c585a79491e Mon Sep 17 00:00:00 2001 From: tiptorrent development team Date: Mon, 13 Sep 2021 12:59:48 +0200 Subject: fix client timeout as described by man(3) ev, to make it work with ev_timer_again(). --- src/core.c | 9 +++++---- 1 file 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; } -- cgit v1.2.3-18-g5258