Fix proxy_close to keep value of in_use

This commit is contained in:
2023-07-06 14:57:06 +02:00
parent b7c8db01ac
commit 0f40dcb5db

View File

@ -139,6 +139,7 @@ proxy_ctx_t *proxy_get_by_conf(host_config_t *conf) {
void proxy_unlock_ctx(proxy_ctx_t *ctx) { void proxy_unlock_ctx(proxy_ctx_t *ctx) {
int n = (int) ((ctx - proxies) / MAX_PROXY_CNX_PER_HOST); int n = (int) ((ctx - proxies) / MAX_PROXY_CNX_PER_HOST);
debug("Released proxy connection slot %i/%i", (ctx - proxies) % MAX_PROXY_CNX_PER_HOST, MAX_PROXY_CNX_PER_HOST);
ctx->in_use = 0; ctx->in_use = 0;
ctx->client = NULL; ctx->client = NULL;
sem_post(&available[n]); sem_post(&available[n]);
@ -368,6 +369,7 @@ int proxy_init(proxy_ctx_t **proxy_ptr, http_req *req, http_res *res, http_statu
*proxy_ptr = proxy_get_by_conf(conf); *proxy_ptr = proxy_get_by_conf(conf);
proxy_ctx_t *proxy = *proxy_ptr; proxy_ctx_t *proxy = *proxy_ptr;
proxy->client = NULL; proxy->client = NULL;
debug("Selected proxy connection slot %i/%i", (proxy - proxies) % MAX_PROXY_CNX_PER_HOST, MAX_PROXY_CNX_PER_HOST);
const char *connection = http_get_header_field(&req->hdr, "Connection"); const char *connection = http_get_header_field(&req->hdr, "Connection");
if (strcontains(connection, "upgrade") || strcontains(connection, "Upgrade")) { if (strcontains(connection, "upgrade") || strcontains(connection, "Upgrade")) {
@ -585,7 +587,10 @@ void proxy_close(proxy_ctx_t *ctx) {
} }
sock_close(&ctx->proxy); sock_close(&ctx->proxy);
ctx->initialized = 0;
memset(ctx, 0, sizeof(*ctx)); ctx->http_timeout = 0;
ctx->cnx_e = 0, ctx->cnx_s = 0;
ctx->client = NULL;
ctx->host = NULL;
errno = 0; errno = 0;
} }