fix recursive lock (#20188)
Costa Tsaousis committed
Apr 27, 2025 at 13:29 UTC
ca6adbb53d7b791d55163a0d22333ba20eefce8b
1 file changed
+8
-3
src/libnetdata/log/nd_log.c
+8
-3
@@ -346,6 +346,8 @@ static void nd_logger(const char *file, const char *function, const unsigned lon
346
if(nd_log.sources[source].pending_msg && spinlock_trylock(&nd_log.sources[source].limits.spinlock)) {
347
// we have to check again if the pending message is still there
348
349
+ bool do_it = false;
350
+
351
if(nd_log.sources[source].pending_msg) {
352
nd_logger_unset_all_thread_fields();
353
@@ -379,15 +381,18 @@ static void nd_logger(const char *file, const char *function, const unsigned lon
381
.uuid = nd_log.sources[source].pending_msgid,
382
};
383
382
- nd_logger_log_fields(
383
- spinlock, fp, false, priority, output, &nd_log.sources[source], thread_log_fields, THREAD_FIELDS_MAX);
384
-
384
freez((void *)nd_log.sources[source].pending_msg);
385
nd_log.sources[source].pending_msg = NULL;
386
nd_log.sources[source].pending_msgid = NULL;
387
+
388
+ do_it = true;
389
}
390
391
spinlock_unlock(&nd_log.sources[source].limits.spinlock);
392
+
393
+ if(do_it)
394
+ nd_logger_log_fields(spinlock, fp, false, priority, output, &nd_log.sources[source],
395
+ thread_log_fields, THREAD_FIELDS_MAX);
396
}
397
398
errno_clear();