diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-10 23:00:36 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-10 23:00:36 +0200 |
commit | 32678c7d4e403c49158434d686ba8b8e450ee011 (patch) | |
tree | 99326b50c286c27ae247d93bb9f4bcf051ad18e8 | |
parent | fd80ac9b3ea3c6e213236e27ae8b73856d2a5158 (diff) |
Improve proxy handling
-rw-r--r-- | proxy.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -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; } |