pespin has uploaded this change for review. ( 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(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-uecups refs/changes/89/40789/1
diff --git a/daemon/gtp_endpoint.c b/daemon/gtp_endpoint.c index 08c0f44..bcd3ce3 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> @@ -135,8 +139,12 @@ { struct gtp_endpoint *ep = (struct gtp_endpoint *)arg; int old_cancelst_unused; + 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 5d71147..3444b2d 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> @@ -200,6 +204,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]; @@ -211,6 +216,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;