From a93b970ab128f64fc14191570562332c31e819fa Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 14 Jan 2011 16:12:32 -0800 Subject: [PATCH] C_Gather: Set debug #ifdefs to remove set. This way when we're confident it works right, we can remove the set and just rely on ref counting. Further optimizations would include using a spinlock rather than a mutex, or possibly even just switching sub_[created|existing]_count to be atomics. Signed-off-by: Greg Farnum --- configure.ac | 2 ++ src/include/Context.h | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 71a00db29d84e..de6b43b853456 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,8 @@ AC_ARG_WITH([debug], [with_debug=no]) AM_CONDITIONAL(WITH_DEBUG, test "$with_debug" = "yes") +AC_DEFINE([DEBUG_GATHER], [1], [Define if you want C_Gather debugging]) + # radosgw? AC_ARG_WITH([radosgw], [AS_HELP_STRING([--with-radosgw], [build RADOS gateway])], diff --git a/src/include/Context.h b/src/include/Context.h index 655ea5b33e0a0..80202b9223837 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -114,7 +114,9 @@ class C_Gather : public Context { private: int result; Context *onfinish; +#ifdef DEBUG_GATHER std::set waitfor; +#endif int sub_created_count; int sub_existing_count; Mutex lock; @@ -123,8 +125,10 @@ private: bool sub_finish(Context* sub, int r) { Mutex::Locker l(lock); +#ifdef DEBUG_GATHER assert(waitfor.count(sub)); waitfor.erase(sub); +#endif --sub_existing_count; //generic_dout(0) << "C_Gather " << this << ".sub_finish(r=" << r << ") " << sub << " " << dendl; @@ -183,7 +187,9 @@ public: ~C_Gather() { //generic_dout(0) << "C_Gather " << this << ".delete" << dendl; assert(sub_existing_count == 0); +#ifdef DEBUG_GATHER assert(waitfor.empty()); +#endif assert(!onfinish); } @@ -198,14 +204,18 @@ public: sub_created_count++; sub_existing_count++; Context *s = new C_GatherSub(this); +#ifdef DEBUG_GATHER waitfor.insert(s); +#endif //generic_dout(0) << "C_Gather " << this << ".new_sub is " << sub_created_count << " " << s << dendl; return s; } void rm_sub(Context *s) { Mutex::Locker l(lock); +#ifdef DEBUG_GATHER assert(waitfor.count(s)); waitfor.erase(s); +#endif sub_existing_count--; } -- 2.39.5