Hm, there still may be some form of race condtion even when properly
locking the mutex from Tcl before destroying it, as in both the
AOLserver 3.3+ad13 and 4.0beta4 C code,
Ns_MutexDestroy
calls
NsLockFree(mPtr->lock)
before calling
Ns_MasterLock()
.
Also, the comment in Ns_MutexDestroy that, "Note this routine is
almost never used as mutexes normally exists in memory until the
process exits." is simply utterly wrong. Mutex destroy functionality
is exposed via the Tcl API, and the Ns_MutexDestroy C function has
absolutely no way to know about or implement any policy on when or why
ns_mutexes are destroyed.