From 7a04638c320c61eb52c0a849fc8cf5ddd6e1ad8c Mon Sep 17 00:00:00 2001 From: tiptorrent development team Date: Mon, 13 Sep 2021 11:54:19 +0200 Subject: update num_clients and redirection only for large files Skip num_clients and redirection update for small files. --- src/core.c | 5 +++-- src/handler.c | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/core.c b/src/core.c index c3d4c03..530c86a 100644 --- a/src/core.c +++ b/src/core.c @@ -50,9 +50,10 @@ static void tip_client_release(struct ev_loop *loop, struct tip_client *cli) free((void *)cli->path); if (cli->method == TIP_METHOD_GET) { - num_clients--; - if (tip_client_large_file(cli)) + if (tip_client_large_file(cli)) { + num_clients--; tip_client_activate_pending(); + } } free(cli); diff --git a/src/handler.c b/src/handler.c index 36d2628..b283ea6 100644 --- a/src/handler.c +++ b/src/handler.c @@ -107,13 +107,15 @@ int tip_client_state_process_payload(struct tip_client *cli) return 0; } - cli->allow_redirect = allow_redirect; - - num_clients++; - if (tip_client_large_file(cli) && num_clients > max_clients) { - if (!tip_client_redirect(cli)) { - tip_client_pending(cli); - return 1; + if (tip_client_large_file(cli)) { + cli->allow_redirect = allow_redirect; + + num_clients++; + if (num_clients > max_clients) { + if (!tip_client_redirect(cli)) { + tip_client_pending(cli); + return 1; + } } } -- cgit v1.2.3-18-g5258