From 32678c7d4e403c49158434d686ba8b8e450ee011 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 10 Jun 2020 23:00:36 +0200 Subject: Improve proxy handling --- proxy.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'proxy.c') diff --git a/proxy.c b/proxy.c index eaa831b..dcae9b6 100644 --- a/proxy.c +++ b/proxy.c @@ -69,13 +69,15 @@ proxy_free(struct uring_task *task) fprintf(stderr, "%s: %s\n", __func__, proxy->scfg->name); - format_time(duration, sizeof(duration), time(NULL) - proxy->begin); - format_bytes(cts, sizeof(cts), proxy->client_bytes); - format_bytes(stc, sizeof(stc), proxy->server_bytes); - - fprintf(stderr, "%s: proxy connection %s -> %s closed (CtS: %s, StC: %s), duration %s\n", - proxy->scfg->name, proxy->clientstr, proxy->serverstr, cts, stc, - duration); + if (proxy->begin > 0) { + format_time(duration, sizeof(duration), time(NULL) - proxy->begin); + format_bytes(cts, sizeof(cts), proxy->client_bytes); + format_bytes(stc, sizeof(stc), proxy->server_bytes); + + fprintf(stderr, "%s: proxy connection %s -> %s closed (CtS: %s, StC: %s), duration %s\n", + proxy->scfg->name, proxy->clientstr, proxy->serverstr, cts, stc, + duration); + } list_del(&proxy->list); xfree(proxy); @@ -102,7 +104,6 @@ proxy_delete(struct cfg *cfg, struct server_proxy *proxy) { fprintf(stderr, "%s: shutting down proxy 0x%p\n", __func__, proxy); - /* FIXME: review half-open proxy situation */ uring_task_destroy(cfg, &proxy->servertask); uring_task_destroy(cfg, &proxy->clienttask); uring_task_destroy(cfg, &proxy->task); @@ -187,7 +188,6 @@ proxy_server_connected(struct cfg *cfg, struct uring_task *task, int res) fprintf(stderr, "%s: connected %i\n", __func__, res); if (res < 0) { - proxy->sfd = -1; uring_task_close_fd(cfg, task); proxy_connect_next_remote(cfg, proxy); return; @@ -220,7 +220,7 @@ again: if (!remote) { fprintf(stderr, "No more remote addresses to attempt\n"); - /* FIXME: put tasks */ + proxy_delete(cfg, proxy); return; } -- cgit v1.2.3