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,29 ****
--- 20,30 ----
   */
  /*
   * 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,95 ****
   */
  /*ARGSUSED*/
  static void *
  server_tsd_bind(void *arg)
  {
!         static void *value = 0;
  
          /* 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);
--- 86,96 ----
   */
  /*ARGSUSED*/
  static void *
  server_tsd_bind(void *arg)
  {
!         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,133 ****
--- 125,135 ----
  server_destroy(void *arg)
  {
          (void) mutex_lock(&create_lock);
          num_servers--;
          (void) mutex_unlock(&create_lock);
+         (void) thr_setspecific(server_key, NULL);
  }
  
  /*
   * get clearance
   */