Do not modify thr stats without locking, otherwise max fd stats were sometimes wrong

This commit is contained in:
Soner Tari 2019-03-16 23:19:48 +03:00
parent 3147723774
commit c43e359a1b
2 changed files with 1 additions and 1 deletions

View File

@ -2004,7 +2004,6 @@ pxy_conn_setup(evutil_socket_t fd,
} }
ctx->af = peeraddr->sa_family; ctx->af = peeraddr->sa_family;
ctx->thr->max_fd = MAX(ctx->thr->max_fd, ctx->fd);
/* determine original destination of connection */ /* determine original destination of connection */
if (spec->natlookup) { if (spec->natlookup) {

View File

@ -555,6 +555,7 @@ pxy_thrmgr_attach(pxy_conn_ctx_t *ctx)
pthread_mutex_lock(&ctx->thr->mutex); pthread_mutex_lock(&ctx->thr->mutex);
ctx->thr->load++; ctx->thr->load++;
ctx->thr->max_load = MAX(ctx->thr->max_load, 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() // 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) // 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); pthread_mutex_unlock(&ctx->thr->mutex);