Changeset: 58398296ba07 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/58398296ba07
Modified Files:
        tools/merovingian/daemon/client.c
        tools/merovingian/daemon/controlrunner.c
        tools/merovingian/daemon/discoveryrunner.c
        tools/merovingian/daemon/merovingian.c
        tools/merovingian/daemon/multiplex-funnel.c
        tools/merovingian/daemon/proxy.c
Branch: Dec2023
Log Message:

Give monetdbd threads names for debugging purposes.


diffs (151 lines):

diff --git a/tools/merovingian/daemon/client.c 
b/tools/merovingian/daemon/client.c
--- a/tools/merovingian/daemon/client.c
+++ b/tools/merovingian/daemon/client.c
@@ -79,6 +79,14 @@ handleClient(void *data)
        bool isusock;
        struct threads *self;
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
+
        sock = ((struct clientdata *) data)->sock;
        isusock = ((struct clientdata *) data)->isusock;
        self = ((struct clientdata *) data)->self;
diff --git a/tools/merovingian/daemon/controlrunner.c 
b/tools/merovingian/daemon/controlrunner.c
--- a/tools/merovingian/daemon/controlrunner.c
+++ b/tools/merovingian/daemon/controlrunner.c
@@ -1154,6 +1154,13 @@ handle_client(void *p)
 {
        int msgsock = * (int *) p;
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
        free(p);
        ctl_handle_client("(local)", msgsock, NULL, NULL);
        shutdown(msgsock, SHUT_RDWR);
@@ -1176,6 +1183,14 @@ controlRunner(void *d)
        pthread_t tid;
        int *p;
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
+
        do {
                if ((p = malloc(sizeof(int))) == NULL) {
                        Mlevelfprintf(ERROR, _mero_ctlerr, "malloc failed\n");
diff --git a/tools/merovingian/daemon/discoveryrunner.c 
b/tools/merovingian/daemon/discoveryrunner.c
--- a/tools/merovingian/daemon/discoveryrunner.c
+++ b/tools/merovingian/daemon/discoveryrunner.c
@@ -318,6 +318,14 @@ discoveryRunner(void *d)
        socks[0] = ((int *) d)[0];
        socks[1] = ((int *) d)[1];
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
+
        /* start shouting around that we're here ;) request others to tell
         * what databases they have */
        snprintf(buf, 512, "HELO %s", _mero_hostname);
diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -239,6 +239,14 @@ logListener(void *x)
 
        (void)x;
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
+
        /* the first entry in the list of d is where our output should go to
         * but we only use the streams, so we don't care about it in the
         * normal loop */
@@ -379,6 +387,13 @@ static void *
 doTerminateProcess(void *p)
 {
        dpair dp = p;
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
        pthread_mutex_lock(&dp->fork_lock);
        (void) terminateProcess(dp->dbname, dp->pid, dp->type);
        pthread_mutex_unlock(&dp->fork_lock);
diff --git a/tools/merovingian/daemon/multiplex-funnel.c 
b/tools/merovingian/daemon/multiplex-funnel.c
--- a/tools/merovingian/daemon/multiplex-funnel.c
+++ b/tools/merovingian/daemon/multiplex-funnel.c
@@ -74,6 +74,14 @@ MFconnectionManager(void *d)
 
        (void)d;
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
+
        while (_mero_keep_listening == 1) {
 #ifdef HAVE_POLL
                pfd = (struct pollfd) {.fd = mfpipe[0], .events = POLLIN};
@@ -714,6 +722,14 @@ multiplexThread(void *d)
        int r, i;
        dpair p, q;
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
+
        /* select on upstream clients, on new data, read query, forward,
         * union all results, send back, and restart cycle. */
 
diff --git a/tools/merovingian/daemon/proxy.c b/tools/merovingian/daemon/proxy.c
--- a/tools/merovingian/daemon/proxy.c
+++ b/tools/merovingian/daemon/proxy.c
@@ -47,6 +47,14 @@ proxyThread(void *d)
        int len;
        char data[8 * 1024];
 
+#ifdef HAVE_PTHREAD_SETNAME_NP
+       pthread_setname_np(
+#ifndef __APPLE__
+               pthread_self(),
+#endif
+               __func__);
+#endif
+
        /* pass everything from in to out, until either reading from in,
         * or writing to out fails, then close the other proxyThread's in
         * and out streams so that it stops as well (it will, or already
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to