From c43e359a1b35cad7a545d35918094f71c6a68dc5 Mon Sep 17 00:00:00 2001 From: Soner Tari Date: Sat, 16 Mar 2019 23:19:48 +0300 Subject: [PATCH] Do not modify thr stats without locking, otherwise max fd stats were sometimes wrong --- pxyconn.c | 1 - pxythrmgr.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pxyconn.c b/pxyconn.c index 2933b52..751cb9d 100644 --- a/pxyconn.c +++ b/pxyconn.c @@ -2004,7 +2004,6 @@ pxy_conn_setup(evutil_socket_t fd, } ctx->af = peeraddr->sa_family; - ctx->thr->max_fd = MAX(ctx->thr->max_fd, ctx->fd); /* determine original destination of connection */ if (spec->natlookup) { diff --git a/pxythrmgr.c b/pxythrmgr.c index 8997542..62df693 100644 --- a/pxythrmgr.c +++ b/pxythrmgr.c @@ -555,6 +555,7 @@ pxy_thrmgr_attach(pxy_conn_ctx_t *ctx) pthread_mutex_lock(&ctx->thr->mutex); ctx->thr->load++; ctx->thr->max_load = MAX(ctx->thr->max_load, ctx->thr->load); + ctx->thr->max_fd = MAX(ctx->thr->max_fd, ctx->fd); // Defer adding the conn to the conn list of its thread until after a successful conn setup while returning from pxy_conn_connect() // otherwise pxy_thrmgr_timer_cb() may try to access the conn ctx while it is being freed on failure (signal 6 crash) pthread_mutex_unlock(&ctx->thr->mutex);