From 574403a39f6f9f90a3b02611c1045cd3193dec17 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 22 Jan 2009 00:17:07 +0000 Subject: [PATCH] fix pstats mutex leaking --- panda/src/pgraph/transformState.h | 2 ++ panda/src/pipeline/mutexDebug.cxx | 7 ++++--- panda/src/pstatclient/pStatClient.I | 8 ++++---- panda/src/pstatclient/pStatClient.cxx | 16 ++++++++-------- panda/src/pstatclient/pStatClient.h | 6 +++--- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 5e36b96191..993e00175d 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -26,7 +26,9 @@ #include "pStatCollector.h" #include "geomEnums.h" #include "lightReMutex.h" +#include "lightReMutexHolder.h" #include "lightMutex.h" +#include "lightMutexHolder.h" #include "config_pgraph.h" #include "deletedChain.h" #include "simpleHashMap.h" diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index d1bd446fff..5bf3082e68 100755 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -148,9 +148,10 @@ do_acquire(Thread *current_thread) { // In this case, it's not a real mutex. Just watch it go by. MissedThreads::iterator mi = _missed_threads.insert(MissedThreads::value_type(current_thread, 0)).first; if ((*mi).second == 0) { - thread_cat.info() - << *current_thread << " not stopped by " << *this << " (held by " - << *_locking_thread << ")\n"; + ostringstream ostr; + ostr << *current_thread << " not stopped by " << *this << " (held by " + << *_locking_thread << ")\n"; + nassert_raise(ostr.str()); } else { if (!_allow_recursion) { ostringstream ostr; diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index 0fb59ef624..bf5457451a 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -75,7 +75,7 @@ get_max_rate() const { //////////////////////////////////////////////////////////////////// INLINE int PStatClient:: get_num_collectors() const { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); return _num_collectors; } @@ -99,7 +99,7 @@ get_collector_def(int index) const { //////////////////////////////////////////////////////////////////// INLINE int PStatClient:: get_num_threads() const { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); return _num_threads; } @@ -211,7 +211,7 @@ resume_after_pause() { //////////////////////////////////////////////////////////////////// INLINE bool PStatClient:: client_connect(string hostname, int port) { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); client_disconnect(); return get_impl()->client_connect(hostname, port); } @@ -261,7 +261,7 @@ has_impl() const { //////////////////////////////////////////////////////////////////// INLINE PStatClientImpl *PStatClient:: get_impl() { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); if (_impl == (PStatClientImpl *)NULL) { _impl = new PStatClientImpl(this); } diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 78c20d86bc..395d2084b2 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -164,7 +164,7 @@ get_collector_fullname(int index) const { //////////////////////////////////////////////////////////////////// PStatThread PStatClient:: get_thread(int index) const { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); nassertr(index >= 0 && index < _num_threads, PStatThread()); return PStatThread((PStatClient *)this, index); } @@ -370,7 +370,7 @@ thread_tick(const string &sync_name) { //////////////////////////////////////////////////////////////////// void PStatClient:: client_main_tick() { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); if (has_impl()) { if (!_impl->client_is_connected()) { client_disconnect(); @@ -400,7 +400,7 @@ client_main_tick() { //////////////////////////////////////////////////////////////////// void PStatClient:: client_thread_tick(const string &sync_name) { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); if (has_impl()) { MultiThingsByName::const_iterator ni = @@ -423,7 +423,7 @@ client_thread_tick(const string &sync_name) { //////////////////////////////////////////////////////////////////// void PStatClient:: client_disconnect() { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); if (has_impl()) { _impl->client_disconnect(); delete _impl; @@ -484,7 +484,7 @@ get_global_pstats() { //////////////////////////////////////////////////////////////////// PStatCollector PStatClient:: make_collector_with_relname(int parent_index, string relname) { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); if (relname.empty()) { relname = "Unnamed"; @@ -524,7 +524,7 @@ make_collector_with_relname(int parent_index, string relname) { //////////////////////////////////////////////////////////////////// PStatCollector PStatClient:: make_collector_with_name(int parent_index, const string &name) { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); nassertr(parent_index >= 0 && parent_index < _num_collectors, PStatCollector()); @@ -593,7 +593,7 @@ do_get_current_thread() const { //////////////////////////////////////////////////////////////////// PStatThread PStatClient:: make_thread(Thread *thread) { - LightReMutexHolder holder(_lock); + ReMutexHolder holder(_lock); return do_make_thread(thread); } @@ -1144,7 +1144,7 @@ activate_hook(Thread *thread) { //////////////////////////////////////////////////////////////////// void PStatClient::Collector:: make_def(const PStatClient *client, int this_index) { - LightReMutexHolder holder(client->_lock); + ReMutexHolder holder(client->_lock); if (_def == (PStatCollectorDef *)NULL) { _def = new PStatCollectorDef(this_index, _name); if (_parent_index != this_index) { diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index a44af5cb06..8d7448e40e 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -20,9 +20,9 @@ #include "pStatFrameData.h" #include "pStatClientImpl.h" #include "pStatCollectorDef.h" -#include "lightReMutex.h" +#include "reMutex.h" #include "lightMutex.h" -#include "lightReMutexHolder.h" +#include "reMutexHolder.h" #include "lightMutexHolder.h" #include "pmap.h" #include "thread.h" @@ -144,7 +144,7 @@ private: private: // This mutex protects everything in this class. - LightReMutex _lock; + ReMutex _lock; typedef pmap ThingsByName; typedef pmap MultiThingsByName;