]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, bgpd: Convert frr_pthread_set_name to only cause it to set os name of the thread 3590/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 9 Jan 2019 19:59:22 +0000 (14:59 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 9 Jan 2019 19:59:22 +0000 (14:59 -0500)
The current invocation of frr_pthread_set_name was causing it reset the os_name.
There is no need for this, we now always create the pthread appropriately
to have both name and os_name.  So convert this function to a simple
call through of the pthread call now.

Before(any of these changes):
sharpd@robot ~/frr1> ps -L -p 16895
  PID   LWP TTY          TIME CMD
16895 16895 ?        00:01:39 bgpd
16895 16896 ?        00:00:54
16895 16897 ?        00:00:07 bgpd_ka

After:
sharpd@donna ~/frr1> ps -L -p 1752
  PID   LWP TTY          TIME CMD
 1752  1752 ?        00:00:00 bgpd
 1752  1753 ?        00:00:00 bgpd_io
 1752  1754 ?        00:00:00 bgpd_ka

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_keepalives.c
lib/frr_pthread.c
lib/frr_pthread.h

index 50aad70ddc56fd70eb5ea32d4292e8b13cd29d33..87e3ff2495270c8285657fcb30146d58f7398fe4 100644 (file)
@@ -181,7 +181,11 @@ void *bgp_keepalives_start(void *arg)
        pthread_cond_init(peerhash_cond, &attrs);
        pthread_condattr_destroy(&attrs);
 
-       frr_pthread_set_name(fpt, NULL, "bgpd_ka");
+       /*
+        * We are not using normal FRR pthread mechanics and are
+        * not using fpt_run
+        */
+       frr_pthread_set_name(fpt);
 
        /* initialize peer hashtable */
        peerhash = hash_create_size(2048, peer_hash_key, peer_hash_cmp, NULL);
index c5aec8ca72437284e9015e502fd2cd9e70a0ba8e..d5a2007c4df64c7b1b1ca3046dcf6ff350516d60 100644 (file)
@@ -117,36 +117,19 @@ void frr_pthread_destroy(struct frr_pthread *fpt)
        XFREE(MTYPE_FRR_PTHREAD, fpt);
 }
 
-int frr_pthread_set_name(struct frr_pthread *fpt, const char *name,
-                        const char *os_name)
+int frr_pthread_set_name(struct frr_pthread *fpt)
 {
        int ret = 0;
 
-       if (name) {
-               pthread_mutex_lock(&fpt->mtx);
-               {
-                       if (fpt->name)
-                               XFREE(MTYPE_FRR_PTHREAD, fpt->name);
-                       fpt->name = XSTRDUP(MTYPE_FRR_PTHREAD, name);
-               }
-               pthread_mutex_unlock(&fpt->mtx);
-               thread_master_set_name(fpt->master, name);
-       }
-
-       if (os_name) {
-               pthread_mutex_lock(&fpt->mtx);
-               snprintf(fpt->os_name, OS_THREAD_NAMELEN, "%s", os_name);
-               pthread_mutex_unlock(&fpt->mtx);
 #ifdef HAVE_PTHREAD_SETNAME_NP
 # ifdef GNU_LINUX
-               ret = pthread_setname_np(fpt->thread, fpt->os_name);
+       ret = pthread_setname_np(fpt->thread, fpt->os_name);
 # else /* NetBSD */
-               ret = pthread_setname_np(fpt->thread, fpt->os_name, NULL);
+       ret = pthread_setname_np(fpt->thread, fpt->os_name, NULL);
 # endif
 #elif defined(HAVE_PTHREAD_SET_NAME_NP)
-               pthread_set_name_np(fpt->thread, fpt->os_name);
+       pthread_set_name_np(fpt->thread, fpt->os_name);
 #endif
-       }
 
        return ret;
 }
@@ -275,15 +258,7 @@ static void *fpt_run(void *arg)
 
        fpt->master->handle_signals = false;
 
-#ifdef HAVE_PTHREAD_SETNAME_NP
-# ifdef GNU_LINUX
-       pthread_setname_np(fpt->thread, fpt->os_name);
-# else /* NetBSD */
-       pthread_setname_np(fpt->thread, fpt->os_name, NULL);
-# endif
-#elif defined(HAVE_PTHREAD_SET_NAME_NP)
-       pthread_set_name_np(fpt->thread, fpt->os_name);
-#endif
+       frr_pthread_set_name(fpt);
 
        frr_pthread_notify_running(fpt);
 
index b9e60511d56aa7e725593e87c8533bad699e1202..e6b3f031b3325447e09235c0e7b4316a03224989 100644 (file)
@@ -133,16 +133,13 @@ struct frr_pthread *frr_pthread_new(struct frr_pthread_attr *attr,
                                    const char *name, const char *os_name);
 
 /*
- * Changes the name of the frr_pthread.
+ * Changes the name of the frr_pthread as reported by the operating
+ * system.
  *
  * @param fpt - the frr_pthread to operate on
- * @param name - Human-readable name
- * @param os_name - 16 characters thread name , including the null
- * terminator ('\0') to set in os.
  * @return -  on success returns 0 otherwise nonzero error number.
  */
-int frr_pthread_set_name(struct frr_pthread *fpt, const char *name,
-                        const char *os_name);
+int frr_pthread_set_name(struct frr_pthread *fpt);
 
 /*
  * Destroys an frr_pthread.