pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-uecups/+/40789?usp=email )
Change subject: Set thread names
......................................................................
Set thread names
Change-Id: I9b44dd9eeb1d8e291c35d1d4a040a1425ba7c305
---
M daemon/gtp_endpoint.c
M daemon/tun_device.c
2 files changed, 16 insertions(+), 1 deletion(-)
Approvals:
osmith: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/daemon/gtp_endpoint.c b/daemon/gtp_endpoint.c
index bb417da..1ad8c27 100644
--- a/daemon/gtp_endpoint.c
+++ b/daemon/gtp_endpoint.c
@@ -1,4 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */
+
+/*pthread.h pthread_setname_np(): */
+#define _GNU_SOURCE
+
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -114,9 +118,12 @@
static void *gtp_endpoint_thread(void *arg)
{
struct gtp_endpoint *ep = (struct gtp_endpoint *)arg;
-
+ char thread_name[16];
uint8_t buffer[sizeof(struct gtp1_header) + sizeof(struct gtp1_exthdr) +
MAX_UDP_PACKET];
+ snprintf(thread_name, sizeof(thread_name), "RxGtpu%s", ep->name);
+ pthread_setname_np(pthread_self(), thread_name);
+
while (1) {
int rc;
diff --git a/daemon/tun_device.c b/daemon/tun_device.c
index 2c67d5c..b32c08a 100644
--- a/daemon/tun_device.c
+++ b/daemon/tun_device.c
@@ -1,4 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */
+
+/*pthread.h pthread_setname_np(): */
+#define _GNU_SOURCE
+
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
@@ -203,6 +207,7 @@
{
struct tun_device *tun = (struct tun_device *)arg;
struct gtp_daemon *d = tun->d;
+ char thread_name[16];
/* Make sure "buffer" below ends up aligned to 4byte so that it can access
struct iphdr in a 4-byte aligned way. */
const size_t payload_off_4byte_aligned = ((sizeof(struct gtp1_header) + sizeof(struct
gtp1_exthdr)) + 3) & (~0x3);
uint8_t base_buffer[payload_off_4byte_aligned + MAX_UDP_PACKET];
@@ -214,6 +219,9 @@
* holding the logging mutex, hence causing deadlock with main (or other)
* thread. */
+ snprintf(thread_name, sizeof(thread_name), "Rx%s", tun->devname);
+ pthread_setname_np(pthread_self(), thread_name);
+
while (1) {
struct gtp_tunnel *t;
struct pkt_info pinfo;
--
To view, visit
https://gerrit.osmocom.org/c/osmo-uecups/+/40789?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-uecups
Gerrit-Branch: master
Gerrit-Change-Id: I9b44dd9eeb1d8e291c35d1d4a040a1425ba7c305
Gerrit-Change-Number: 40789
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>