diff options
author | tiptorrent development team <tiptorrent@soleta.eu> | 2021-09-19 22:42:48 +0200 |
---|---|---|
committer | tiptorrent development team <tiptorrent@soleta.eu> | 2021-09-29 15:48:59 +0200 |
commit | 44287f9e6722bcdbdb2cda679407a265697cbeb7 (patch) | |
tree | 0715e76fcf00115a4ef588f6d4efa491537a44a4 /src | |
parent | 21e905a3875f5da9ec36393c5d9987487920f00b (diff) |
do not activate clients without redirection via POST
update 4573deb8cb3 to skip clients without redirection after
receiving POST notification.
Diffstat (limited to 'src')
-rw-r--r-- | src/core.c | 9 | ||||
-rw-r--r-- | src/core.h | 2 | ||||
-rw-r--r-- | src/handler.c | 2 |
3 files changed, 8 insertions, 5 deletions
@@ -51,7 +51,7 @@ static void tip_client_release(struct ev_loop *loop, struct tip_client *cli) if (cli->method == TIP_METHOD_GET) { if (tip_client_large_file(cli)) { num_clients--; - tip_client_activate_pending(); + tip_client_activate_pending(false); } } @@ -351,15 +351,18 @@ void tip_client_pending(struct tip_client *cli) cli->state = TIP_CLIENT_PENDING; } -void tip_client_activate_pending(void) +void tip_client_activate_pending(bool redirect_only) { struct tip_client *cli, *next; + bool redirected; list_for_each_entry_safe(cli, next, &client_list, list) { if (cli->state != TIP_CLIENT_PENDING) continue; + redirected = tip_client_redirect(cli); + if (!redirected && redirect_only) + continue; - tip_client_redirect(cli); ev_io_set(&cli->io, tip_client_socket(cli), EV_READ | EV_WRITE); ev_io_start(tip_main_loop, &cli->io); ev_timer_again(tip_main_loop, &cli->timer); @@ -71,7 +71,7 @@ static inline bool tip_client_large_file(const struct tip_client *cli) void tip_client_pending(struct tip_client *cli); bool tip_client_redirect(struct tip_client *cli); int tip_client_redirect_create(const struct tip_client *cli); -void tip_client_activate_pending(void); +void tip_client_activate_pending(bool redirect_only); extern struct ev_loop *tip_main_loop; diff --git a/src/handler.c b/src/handler.c index 14abe9b..54c2c1b 100644 --- a/src/handler.c +++ b/src/handler.c @@ -115,7 +115,7 @@ int tip_client_state_process_payload(struct tip_client *cli) case TIP_METHOD_POST: cli->allow_redirect = true; tip_client_redirect_create(cli); - tip_client_activate_pending(); + tip_client_activate_pending(true); cli->state = TIP_CLIENT_PROCESSING_REQUEST_2; return 0; } |