summaryrefslogtreecommitdiffstats
path: root/lib/zlog.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-04-11 03:59:25 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-06-18 21:05:21 +0200
commit78598fd0195510d0d1338bf8c28e606d67e63359 (patch)
tree16748cd339dfa0636eb1c6afb3a6803aef927120 /lib/zlog.h
parentlib: include `\n` in zlog_msg_text() (diff)
downloadfrr-78598fd0195510d0d1338bf8c28e606d67e63359.tar.xz
frr-78598fd0195510d0d1338bf8c28e606d67e63359.zip
lib: cache PID & TID in zlog code
glibc removed its pid cache a while back, and grabbing this from TLS is faster than repeatedly calling the kernel... Also use `intmax_t` which is more appropriate for both PID & TID. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/zlog.h')
-rw-r--r--lib/zlog.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/zlog.h b/lib/zlog.h
index 1b03e3fd1..7fd7b0e5c 100644
--- a/lib/zlog.h
+++ b/lib/zlog.h
@@ -178,6 +178,11 @@ extern size_t zlog_msg_ts(struct zlog_msg *msg, struct fbuf *out,
extern size_t zlog_msg_ts_3164(struct zlog_msg *msg, struct fbuf *out,
uint32_t flags);
+/* currently just returns the current PID/TID since we never write another
+ * thread's messages
+ */
+extern void zlog_msg_pid(struct zlog_msg *msg, intmax_t *pid, intmax_t *tid);
+
/* This list & struct implements the actual logging targets. It is accessed
* lock-free from all threads, and thus MUST only be changed atomically, i.e.
* RCU.