This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22920 ) Change subject: logging: gsmtap: Fill PID field for each message ...................................................................... logging: gsmtap: Fill PID field for each message It was recently discovered that PID field in gsmtap log messages was always set to 0. Before this patch, the field was never being set. The approach of this patch is to record the PID of the process once during tgt creation, in order to avoid calling getpid() syscall on each log line to be sent. The counterpart of this optimization is that eventual fork() calls would still keep the old incorrect value, but I think nobody can safely assume that fork() is possible once all this kind of infrastructure has already been configured (fork() should only be done really at the start of the program before any osmocom foo is initialized). Change-Id: I7db00d1810f0860166bffa0bda8566caa82e06a9 --- M include/osmocom/core/logging.h M src/logging_gsmtap.c 2 files changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/22920/1 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index c7f89de..c4068a0 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -314,6 +314,7 @@ struct gsmtap_inst *gsmtap_inst; const char *ident; const char *hostname; + uint32_t pid; } tgt_gsmtap; struct { diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c index bd64271..9930419 100644 --- a/src/logging_gsmtap.c +++ b/src/logging_gsmtap.c @@ -38,6 +38,7 @@ #include <stdio.h> #include <string.h> #include <stdbool.h> +#include <unistd.h> #ifdef HAVE_STRINGS_H #include <strings.h> @@ -82,6 +83,7 @@ /* 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 = target->tgt_gsmtap.pid; if (subsys_name) OSMO_STRLCPY_ARRAY(golh->subsys, subsys_name + 1); else @@ -148,6 +150,7 @@ target->tgt_gsmtap.gsmtap_inst = gti; target->tgt_gsmtap.ident = talloc_strdup(target, ident); target->tgt_gsmtap.hostname = talloc_strdup(target, host); + target->tgt_gsmtap.pid = (uint32_t)getpid(); target->type = LOG_TGT_TYPE_GSMTAP; target->raw_output = _gsmtap_raw_output; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22920 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I7db00d1810f0860166bffa0bda8566caa82e06a9 Gerrit-Change-Number: 22920 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210215/e9a378b4/attachment.htm>