Use a better pattern for "create mutex if not already initialized"
Tor relies on double checked locking for various threading initializations. Double checked locking is not guaranteed to work.
For Posix: 4.11, Memory Synchronization: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html
Applications shall ensure that access to any memory location by more than one thread of control (threads or processes) is restricted such that no thread of control can read or modify a memory location while another thread of control may be modifying it.
Race conditions: compat_pthreads.c:threads_initialized
log.c:log_mutex_initialized
Mutex static initialization is supported by pthreads via PTHREAD_MUTEX_INITIALIZER.