pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmocore/+/42085?usp=email )
Change subject: logging: Fix print tid value in multithreadded programs
......................................................................
logging: Fix print tid value in multithreadded programs
Change-Id: I363751ab1368d916aad8905b056ec4f9d62b7175
---
M src/core/logging.c
1 file changed, 9 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/42085/1
diff --git a/src/core/logging.c b/src/core/logging.c
index db5433e..acfdf3c 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -606,9 +606,15 @@
OSMO_STRBUF_PRINTF(sb, " ");
}
if (target->print_tid) {
- if (log_thread_state.tid == 0)
- log_thread_state.tid = (long int)osmo_gettid();
- OSMO_STRBUF_PRINTF(sb, "%ld ", log_thread_state.tid);
+ long int tid;
+ if (!osmo_log_tgt_mutex_on) {
+ tid = log_thread_state.tid;
+ if (OSMO_UNLIKELY(tid == 0))
+ tid = log_thread_state.tid = (long
int)osmo_gettid();
+ } else {
+ tid = (long int)osmo_gettid();
+ }
+ OSMO_STRBUF_PRINTF(sb, "%ld ", tid);
}
if (target->print_category)
OSMO_STRBUF_PRINTF(sb, "%s%s%s%s ",
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/42085?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I363751ab1368d916aad8905b056ec4f9d62b7175
Gerrit-Change-Number: 42085
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>