aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-02-17 18:55:44 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-02-17 18:55:46 +0100
commit74dddefcc76f15540c628af45eae3d8bc58dc452 (patch)
treeab10e04900a241a102b47647e6940460e1321f76 /src
parent2f765f02af074a8c0147bdfac0772a4635c99e3f (diff)
logging: gsmtap: Store TID instead of PID in pkt hdr
This allows differentiating threads withing an application, while still keeping same numbering for single-threaded application (since first thread ID is always the same as the process group ID). Related: OS#5027 Change-Id: I33da02524fc064e133b2b762af7060139c4cfd81
Diffstat (limited to 'src')
-rw-r--r--src/logging_gsmtap.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c
index 05246023..e190f88f 100644
--- a/src/logging_gsmtap.c
+++ b/src/logging_gsmtap.c
@@ -51,10 +51,11 @@
#include <osmocom/core/logging.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/byteswap.h>
+#include <osmocom/core/thread.h>
#define GSMTAP_LOG_MAX_SIZE 4096
-static uint32_t logging_gsmtap_pid;
+static __thread uint32_t logging_gsmtap_tid;
static void _gsmtap_raw_output(struct log_target *target, int subsys,
unsigned int level, const char *file,
@@ -85,7 +86,9 @@ static void _gsmtap_raw_output(struct log_target *target, int subsys,
/* Logging header */
golh = (struct gsmtap_osmocore_log_hdr *) msgb_put(msg, sizeof(*golh));
OSMO_STRLCPY_ARRAY(golh->proc_name, target->tgt_gsmtap.ident);
- golh->pid = logging_gsmtap_pid;
+ if (logging_gsmtap_tid == 0)
+ osmo_store32be((uint32_t)osmo_gettid(), &logging_gsmtap_tid);
+ golh->pid = logging_gsmtap_tid;
if (subsys_name)
OSMO_STRLCPY_ARRAY(golh->subsys, subsys_name + 1);
else
@@ -156,9 +159,6 @@ struct log_target *log_target_create_gsmtap(const char *host, uint16_t port,
target->type = LOG_TGT_TYPE_GSMTAP;
target->raw_output = _gsmtap_raw_output;
- if (!logging_gsmtap_pid)
- osmo_store32be((uint32_t)getpid(), &logging_gsmtap_pid);
-
return target;
}