Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section

@@ -20,10 +20,11 @@
  */
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  * Copyright 2012 Milan Jurik. All rights reserved.
+ * Copyright 2018 Joyent, Inc.
  */
 
 #include <stdlib.h>
 #include <alloca.h>
 #include <signal.h>

@@ -87,10 +88,12 @@
 static void *
 server_tsd_bind(void *arg)
 {
         static void *value = 0;
 
+        (void) thr_setname(thr_self(), "server_tsd_bind");
+
         /* disable cancellation to avoid hangs if server threads disappear */
         (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
         (void) thr_setspecific(server_key, value);
         (void) door_return(NULL, 0, NULL, 0);
 

@@ -130,11 +133,12 @@
 
 /*
  * get clearance
  */
 int
-_nscd_get_clearance(sema_t *sema) {
+_nscd_get_clearance(sema_t *sema)
+{
         if (sema_trywait(&common_sema) == 0) {
                 (void) thr_setspecific(lookup_state_key, NULL);
                 return (0);
         }
 

@@ -149,11 +153,12 @@
 
 /*
  * release clearance
  */
 int
-_nscd_release_clearance(sema_t *sema) {
+_nscd_release_clearance(sema_t *sema)
+{
         int     which;
 
         (void) thr_getspecific(lookup_state_key, (void**)&which);
         if (which == 0) /* from common pool */ {
                 (void) sema_post(&common_sema);

@@ -1475,10 +1480,12 @@
                 struct ifa_msghdr ifam;
         } mbuf;
         struct ifa_msghdr *ifam = &mbuf.ifam;
         char    *me = "rts_mon";
 
+        (void) thr_setname(thr_self(), me);
+
         rt_sock = socket(PF_ROUTE, SOCK_RAW, 0);
         if (rt_sock < 0) {
                 _NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_ERROR)
                 (me, "Failed to open routing socket: %s\n", strerror(errno));
                 thr_exit(0);