diff --git a/dtool/src/dtoolbase/mutexImpl.h b/dtool/src/dtoolbase/mutexImpl.h index aa1ee81824..c80c8d4e06 100644 --- a/dtool/src/dtoolbase/mutexImpl.h +++ b/dtool/src/dtoolbase/mutexImpl.h @@ -42,12 +42,6 @@ typedef MutexWin32Impl MutexImpl; typedef MutexWin32Impl ReMutexImpl; // Win32 Mutexes are always reentrant. #define HAVE_REMUTEXIMPL 1 -#elif defined(THREAD_LINUX_IMPL) - -#include "mutexLinuxImpl.h" -typedef MutexLinuxImpl MutexImpl; -#undef HAVE_REMUTEXIMPL // The futex implementation is non-reentrant. - #elif defined(THREAD_POSIX_IMPL) #include "mutexPosixImpl.h" diff --git a/dtool/src/dtoolbase/typeRegistry.I b/dtool/src/dtoolbase/typeRegistry.I index ae7a025b94..0eb0b070c8 100644 --- a/dtool/src/dtoolbase/typeRegistry.I +++ b/dtool/src/dtoolbase/typeRegistry.I @@ -39,7 +39,7 @@ freshen_derivations() { //////////////////////////////////////////////////////////////////// INLINE void TypeRegistry:: init_lock() { - if (_lock == (ReMutexImpl *)NULL) { - _lock = new ReMutexImpl; + if (_lock == (MutexImpl *)NULL) { + _lock = new MutexImpl; } } diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index 4a618377b1..ad274a4e6a 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -25,7 +25,7 @@ #include -ReMutexImpl *TypeRegistry::_lock = NULL; +MutexImpl *TypeRegistry::_lock = NULL; TypeRegistry *TypeRegistry::_global_pointer = NULL; //////////////////////////////////////////////////////////////////// @@ -524,17 +524,7 @@ reregister_types() { void TypeRegistry:: write(ostream &out) const { _lock->lock(); - // Recursively write out the tree, starting from each node that has - // no parent. - HandleRegistry::const_iterator hi; - for (hi = _handle_registry.begin(); - hi != _handle_registry.end(); - ++hi) { - const TypeRegistryNode *root = *hi; - if (root != NULL && root->_parent_classes.empty()) { - write_node(out, 2, root); - } - } + do_write(out); _lock->release(); } @@ -632,11 +622,32 @@ rebuild_derivations() { } } +//////////////////////////////////////////////////////////////////// +// Function: TypeRegistry::do_write +// Access: Private +// Description: The private implementation of write(), this assumes +// the lock is already held. +//////////////////////////////////////////////////////////////////// +void TypeRegistry:: +do_write(ostream &out) const { + // Recursively write out the tree, starting from each node that has + // no parent. + HandleRegistry::const_iterator hi; + for (hi = _handle_registry.begin(); + hi != _handle_registry.end(); + ++hi) { + const TypeRegistryNode *root = *hi; + if (root != NULL && root->_parent_classes.empty()) { + write_node(out, 2, root); + } + } +} + //////////////////////////////////////////////////////////////////// // Function: TypeRegistry::write_node // Access: Private // Description: Writes a single TypeRegistryNode out, along with all of -// its descendants. +// its descendants. Assumes the lock is already held. //////////////////////////////////////////////////////////////////// void TypeRegistry:: write_node(ostream &out, int indent_level, const TypeRegistryNode *node) const { @@ -666,6 +677,8 @@ write_node(ostream &out, int indent_level, const TypeRegistryNode *node) const { // the object that owns the handle, if available. It is // only used in an error condition, if for some reason // the handle was uninitialized. +// +// Assumes the lock is already held. //////////////////////////////////////////////////////////////////// TypeRegistryNode *TypeRegistry:: look_up(TypeHandle handle, TypedObject *object) const { @@ -675,8 +688,11 @@ look_up(TypeHandle handle, TypedObject *object) const { if (object != NULL) { // But we're lucky enough to have a TypedObject pointer handy! - // Maybe we can use it to resolve the error. + // Maybe we can use it to resolve the error. We have to drop + // the lock while we do this, so we don't get a recursive lock. + _lock->release(); handle = object->force_init_type(); + _lock->lock(); if (handle._index == 0) { // Strange. cerr diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index 2332c91723..185e40115e 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -95,6 +95,8 @@ private: INLINE void freshen_derivations(); void rebuild_derivations(); + + void do_write(ostream &out) const; void write_node(ostream &out, int indent_level, const TypeRegistryNode *node) const; @@ -111,7 +113,7 @@ private: bool _derivations_fresh; - static ReMutexImpl *_lock; + static MutexImpl *_lock; static TypeRegistry *_global_pointer; friend class TypeHandle; diff --git a/dtool/src/parser-inc/windows.h b/dtool/src/parser-inc/windows.h index 49d955f8cc..7e9830209d 100644 --- a/dtool/src/parser-inc/windows.h +++ b/dtool/src/parser-inc/windows.h @@ -26,6 +26,7 @@ typedef bool BOOL; typedef long DWORD; +typedef long LONG; typedef unsigned long ULONG; typedef long HRESULT; typedef int CRITICAL_SECTION; diff --git a/panda/src/pipeline/mutexTrueImpl.h b/panda/src/pipeline/mutexTrueImpl.h index a2197d1bc3..122b598a78 100644 --- a/panda/src/pipeline/mutexTrueImpl.h +++ b/panda/src/pipeline/mutexTrueImpl.h @@ -47,7 +47,9 @@ typedef ReMutexSimpleImpl ReMutexTrueImpl; #else typedef MutexImpl MutexTrueImpl; +#if HAVE_REMUTEXIMPL typedef ReMutexImpl ReMutexTrueImpl; +#endif // HAVE_REMUTEXIMPL #endif