From e61d16fb4107435918ceddb28c0a3779c1f86d87 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Thu, 7 Jan 2021 22:35:49 +0100 Subject: [PATCH] Hopefully bugfix --- src/rev_proxy.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rev_proxy.c b/src/rev_proxy.c index e7d147a..a4cc3b4 100644 --- a/src/rev_proxy.c +++ b/src/rev_proxy.c @@ -16,6 +16,8 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client char * err_msg) { char buffer[CHUNK_SIZE]; long ret; + int new = 0; + int retry = 0; if (rev_proxy.socket != 0 && rev_proxy_host == conf->name) { goto rev_proxy; @@ -23,6 +25,10 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client sock_close(&rev_proxy); } + retry: + retry = 0; + new = 1; + rev_proxy.socket = socket(AF_INET6, SOCK_STREAM, 0); if (rev_proxy.socket < 0) { print(ERR_STR "Unable to create socket: %s" CLR_STR, strerror(errno)); @@ -97,6 +103,7 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client res->status = http_get_status(502); print(ERR_STR "Unable to send request to server: %s" CLR_STR, sock_strerror(&rev_proxy)); sprintf(err_msg, "Unable to send request to server: %s.", sock_strerror(&rev_proxy)); + retry = !new; goto proxy_err; } @@ -113,6 +120,7 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client res->status = http_get_status(502); print(ERR_STR "Unable to send request to server: %s" CLR_STR, sock_strerror(&rev_proxy)); sprintf(err_msg, "Unable to send request to server: %s.", sock_strerror(&rev_proxy)); + retry = !new; goto proxy_err; } content_len -= len; @@ -123,6 +131,7 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client res->status = http_get_status(502); print(ERR_STR "Unable to send request to server: %s" CLR_STR, sock_strerror(&rev_proxy)); sprintf(err_msg, "Unable to send request to server: %s.", sock_strerror(&rev_proxy)); + retry = !new; goto proxy_err; } } @@ -133,6 +142,7 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client res->status = http_get_status(502); print(ERR_STR "Unable to receive response from server: %s" CLR_STR, sock_strerror(&rev_proxy)); sprintf(err_msg, "Unable to receive response from server: %s.", sock_strerror(&rev_proxy)); + retry = !new; goto proxy_err; } @@ -205,6 +215,9 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client proxy_err: print(BLUE_STR "Closing proxy connection" CLR_STR); sock_close(&rev_proxy); + if (retry) { + goto retry; + } return -1; }