pespin has uploaded this change for review.
logging: Also Avoid infinite loop/deadlock in log_check_level()
A LOG() macro being called inside an already-logging path will first
call log_check_level() before calling osmo_vlogp(). Since calling
happens with the mutex hold, it has been seen to deadlock in eg.
osmo-hnbgw.
Change-Id: I0098629b335b3aa174b49fd79c33d22b04bc4785
---
M src/core/logging.c
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/41986/1
diff --git a/src/core/logging.c b/src/core/logging.c
index 60634af..db5433e 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -753,7 +753,8 @@
if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
/* Avoid re-entrant logging: If logging to log target generates
* extra logging (eg. an error log line due to some wqueue being full),
- * we may end up in an infinite loop. */
+ * we may end up in an infinite loop, or deadlock trying to re-acquire
+ * this same lock. */
return;
}
log_thread_state.logging_active = true;
@@ -1397,6 +1398,13 @@
/* TODO: The following could/should be cached (update on config) */
+ if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
+ /* Avoid re-entrant logging: If logging to log target generates
+ * extra logging (eg. an error log line due to some wqueue being full),
+ * we may end up in an infinite loop, or deadlock trying to re-acquire
+ * this same lock. */
+ return 0;
+ }
log_tgt_mutex_lock();
llist_for_each_entry(tar, &osmo_log_target_list, entry) {
To view, visit change 41986. To unsubscribe, or for help writing mail filters, visit settings.