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>

@@ -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 2019 Nexenta Systems, Inc.
  */
 
 #include <stdlib.h>
 #include <alloca.h>
 #include <signal.h>

@@ -85,11 +86,11 @@
  */
 /*ARGSUSED*/
 static void *
 server_tsd_bind(void *arg)
 {
-        static void *value = 0;
+        static void *value = "NON-NULL TSD";
 
         /* 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);

@@ -124,10 +125,11 @@
 server_destroy(void *arg)
 {
         (void) mutex_lock(&create_lock);
         num_servers--;
         (void) mutex_unlock(&create_lock);
+        (void) thr_setspecific(server_key, NULL);
 }
 
 /*
  * get clearance
  */