]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix locking. Helps with #4465
authorAlan T. DeKok <aland@freeradius.org>
Tue, 26 Apr 2022 13:00:34 +0000 (09:00 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 26 Apr 2022 13:00:47 +0000 (09:00 -0400)
src/modules/rlm_stats/rlm_stats.c

index 7ce02a23d4ce29d28b06d9679a37530d13ff5d58..fbdafef9f3cf46e9d66ea76cb730859340dbbc30 100644 (file)
@@ -135,13 +135,14 @@ static void coalesce(uint64_t final_stats[FR_RADIUS_CODE_MAX], rlm_stats_thread_
             other = fr_dlist_next(&t->inst->list, other)) {
                int i;
 
-               pthread_mutex_lock(&other->mutex);
-
                if (other == t) continue;
 
                tree = (fr_rb_tree_t **) (((uint8_t *) other) + tree_offset);
+               pthread_mutex_lock(&other->mutex);
                stats = fr_rb_find(*tree, mydata);
+
                if (!stats) {
+                       pthread_mutex_unlock(&other->mutex);
                        continue;
                }
                memcpy(&local_stats, stats->stats, sizeof(stats->stats));