Bug #11004

Updated by Gordon Ross about 5 years ago

In investigating #11039, it was discovered that some door servers fail to cause thread counts to decrement on thread exit. 

 Door servers can register their own thread-creation functions. These functions can maintain whatever size thread pool they want, and can block requests if too many threads are active. However, they must ensure that at least one thread is available to server requests. 

 Many of these 'limiting' door servers use thread-specific data to decrement the number of active threads in the case that a thread exists. However, nearly all of them set the TSD value to NULL, which means the destructor never gets called, and so the thread count is never decremented. This could lead to a complete depletion of the thread pool, and so no new door requests can be served. 

 Note that, under normal circumstances, door server threads never exit - they're supposed to use 'door_return' instead of allowing an exit - and so this should only happen due to programming errors. Thread exit should still be handled appropriately, particularly in the presence of library code. 

 idmapd, nscd, and ldapcachemgr all use TSDs to handle this, but set 'value' to NULL. nfs-mountd also uses TSD destructors to handle thread counts, but selectively sets 'value' to 1 for reasons that aren't clear, and as such isn't included in this bug. 

 Found by code inspection; There is no known method to test this, and it's unclear if any threads actually exit.