]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Deal with remaining missing locks (CIDs listed below)
authorJames Jones <jejones3141@gmail.com>
Tue, 21 Nov 2023 21:53:47 +0000 (15:53 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 1 Feb 2024 16:01:55 +0000 (10:01 -0600)
CIDs: 1551700155170115517041551705

src/lib/server/pool.c
src/lib/util/atexit.c

index 7dc4030743e97a43c2853bac27a89c9abcaa75d6..7f58b949ec0d53cd54f8d2fab5f9be2289c991f3 100644 (file)
@@ -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;
 
                /*
index 71181a0586e3e2077149f13d6afe0c7ef2370090..de66df56f3c26b149e0987cd952f0a0f655ad4c8 100644 (file)
@@ -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;
 }