aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/gpr
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-09-26 17:43:14 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-09-27 10:08:19 -0700
commitd5d881ae9f30dd91c820a97254f56ed36c116454 (patch)
treeccbf4462d7fbfc6aedd230fef33ad7080211c5cc /src/core/lib/gpr
parente58edaebdc5e12edb6761006a3e150ea9ba9d043 (diff)
Core infrastructure for timer manager debug
Diffstat (limited to 'src/core/lib/gpr')
-rw-r--r--src/core/lib/gpr/sync_posix.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/core/lib/gpr/sync_posix.cc b/src/core/lib/gpr/sync_posix.cc
index 848d23730c..ce2a5ca31a 100644
--- a/src/core/lib/gpr/sync_posix.cc
+++ b/src/core/lib/gpr/sync_posix.cc
@@ -27,6 +27,15 @@
#include <time.h>
#include "src/core/lib/profiling/timers.h"
+// For debug only. Forward statistics to another module.
+void (*g_grpc_debug_timer_manager_stats)(int64_t timer_manager_init_count, int64_t timer_manager_shutdown_count, int64_t fork_count, int64_t timer_wait_err, int64_t timer_wait_cv) = nullptr;
+// For debug only. Variables storing the counters being logged.
+int64_t g_timer_manager_init_count = 0;
+int64_t g_timer_manager_shutdown_count = 0;
+int64_t g_fork_count = 0;
+int64_t g_timer_wait_err = 0;
+int64_t g_timer_wait_cv = 0;
+
#ifdef GPR_LOW_LEVEL_COUNTERS
gpr_atm gpr_mu_locks = 0;
gpr_atm gpr_counter_atm_cas = 0;
@@ -88,7 +97,18 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
}
- GPR_ASSERT(err == 0 || err == ETIMEDOUT || err == EAGAIN);
+ if (!(err == 0 || err == ETIMEDOUT || err == EAGAIN)) {
+ if (g_grpc_debug_timer_manager_stats) {
+ g_timer_wait_err = err;
+ g_timer_wait_cv = (int64_t)cv;
+ g_grpc_debug_timer_manager_stats(g_timer_manager_init_count,
+ g_timer_manager_shutdown_count,
+ g_fork_count,
+ g_timer_wait_err,
+ g_timer_wait_cv);
+ }
+ GPR_ASSERT(err == 0 || err == ETIMEDOUT || err == EAGAIN);
+ }
return err == ETIMEDOUT;
}