Print this page
NEX-19665 Several door servers don't properly handle exiting threads
Review by: Gordon Ross <gordon.ross@nexenta.com>
Review by: Evan Layton <evan.layton@nexenta.com>
        
@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2019 Nexenta Systems, Inc.
  */
 
 /*
  * Simple doors ldap cache daemon
  */
@@ -223,17 +224,17 @@
 
 /*ARGSUSED*/
 static void *
 server_tsd_bind(void *arg)
 {
-        static void     *value = 0;
+        static void *value = "NON-NULL TSD";
 
         /*
          * disable cancellation to prevent hangs when server
          * threads disappear
          */
-
+        (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
         (void) thr_setspecific(server_key, value);
         (void) door_return(NULL, 0, NULL, 0);
 
         return (value);
 }
@@ -266,10 +267,11 @@
 server_destroy(void *arg)
 {
         (void) mutex_lock(&create_lock);
         num_servers--;
         (void) mutex_unlock(&create_lock);
+        (void) thr_setspecific(server_key, NULL);
 }
 
 static void             client_killserver();
 
 int