Bug #5027
closedlogging_gsmtap.c code not filling PID field in pkt header
100%
Description
It was recently discovered that the PID field was always sent as 0.
This first patch fixes the issue:
https://gerrit.osmocom.org/c/libosmocore/+/22920
During patch review, a discussion was started on possible improvements.
The idea is to instead of getpid(), fill it gettid() to be able to distinguish threads.
gettid() support in system is sometimes a bit flacky. osmo-trx already solves that by implemeting its own wrapper "my_gettid" based on autoconf detection in debug.c.
We should move that "my_gettid" implementation as "osmo_gettid()" and put it in some "thread_compat.h" in libosmocore, similar to what we do with "timer_compat.h" timespec operations.
Then, in libosmocore's logging_gsmtap.c, change the static global variable logging_gsmtap_pid to be __thread, and update it each time _gsmtap_raw_output() is called if value is 0.
Finally, remove the "my_gettid" from osmo-trx and use the libosmocore one.
Related issues