From: James Jones Date: Tue, 21 Nov 2023 21:53:47 +0000 (-0600) Subject: Deal with remaining missing locks (CIDs listed below) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ff40fb79a958a2f7c40e8b80f431de47da73932;p=thirdparty%2Ffreeradius-server.git Deal with remaining missing locks (CIDs listed below) CIDs: 1551700, 1551701, 1551704, 1551705 --- diff --git a/src/lib/server/pool.c b/src/lib/server/pool.c index 7dc4030743e..7f58b949ec0 100644 --- a/src/lib/server/pool.c +++ b/src/lib/server/pool.c @@ -410,15 +410,6 @@ static fr_pool_connection_t *connection_spawn(fr_pool_t *pool, request_t *reques */ while (pool->state.reconnecting) pthread_cond_wait(&pool->done_reconnecting, &pool->mutex); - /* - * Unlock the mutex while we try to open a new - * connection. If there are issues with the back-end, - * opening a new connection may take a LONG time. In - * that case, we want the other connections to continue - * to be used. - */ - pthread_mutex_unlock(&pool->mutex); - /* * The true value for pending_window is the smaller of * free connection slots, or pool->pending_window. @@ -428,6 +419,15 @@ static fr_pool_connection_t *connection_spawn(fr_pool_t *pool, request_t *reques ROPTIONAL(RDEBUG2, DEBUG2, "Opening additional connection (%" PRIu64 "), %u of %u pending slots used", number, pool->state.pending, pending_window); + /* + * Unlock the mutex while we try to open a new + * connection. If there are issues with the back-end, + * opening a new connection may take a LONG time. In + * that case, we want the other connections to continue + * to be used. + */ + pthread_mutex_unlock(&pool->mutex); + /* * Allocate a new top level ctx for the create callback * to hang its memory off of. @@ -735,8 +735,10 @@ static int connection_check(fr_pool_t *pool, request_t *request) close_connection: /* * Don't close connections too often, in order to - * prevent flapping. + * prevent flapping. Coverity doesn't notice that + * all callers have the lock, so we annotate the issue. */ + /* coverity[missing_lock] */ if (fr_time_lt(now, fr_time_add(pool->state.last_spawned, pool->delay_interval))) goto manage_connections; /* diff --git a/src/lib/util/atexit.c b/src/lib/util/atexit.c index 71181a0586e..de66df56f3c 100644 --- a/src/lib/util/atexit.c +++ b/src/lib/util/atexit.c @@ -433,7 +433,9 @@ static int _thread_local_list_free(fr_atexit_list_t *list) ATEXIT_DEBUG("%s - Freeing _Thread_local destructor list %p", __FUNCTION__, list); fr_dlist_talloc_free(&list->head); /* Free in order */ + pthread_mutex_lock(&fr_atexit_global_mutex); list->e->func = NULL; /* Disarm the global entry that'd free the thread-specific list */ + pthread_mutex_unlock(&fr_atexit_global_mutex); return 0; }