reviewer feedback

reviewable/pr13109/r18
ncteisen 7 years ago
parent b2aa06ae99
commit c4dd9cfe18
  1. 16
      src/core/lib/debug/trace.cc
  2. 19
      src/core/lib/debug/trace.h
  3. 8
      test/core/iomgr/timer_list_test.cc
  4. 3
      test/core/transport/connectivity_state_test.cc
  5. 2
      test/core/util/tracer_peer.cc
  6. 2
      test/core/util/tracer_peer.h

@ -29,13 +29,7 @@ int grpc_tracer_set_enabled(const char* name, int enabled);
namespace grpc_core {
TraceFlagList* TraceFlagList::instance_ = nullptr;
TraceFlagList* TraceFlagList::Get() {
if (instance_ == nullptr)
instance_ = static_cast<TraceFlagList*>(gpr_malloc(sizeof(TraceFlagList)));
return instance_;
}
TraceFlag* TraceFlagList::root_tracer_ = nullptr;
bool TraceFlagList::Set(const char* name, bool enabled) {
TraceFlag* t;
@ -83,7 +77,7 @@ void TraceFlagList::LogAllTracers() {
// Flags register themselves on the list during construction
TraceFlag::TraceFlag(bool default_enabled, const char* name)
: name_(name), value_(default_enabled) {
TraceFlagList::Get()->Add(this);
TraceFlagList::Add(this);
}
} // namespace grpc_core
@ -121,9 +115,9 @@ static void parse(const char* s) {
for (i = 0; i < nstrings; i++) {
if (strings[i][0] == '-') {
grpc_core::TraceFlagList::Get()->Set(strings[i] + 1, false);
grpc_core::TraceFlagList::Set(strings[i] + 1, false);
} else {
grpc_core::TraceFlagList::Get()->Set(strings[i], true);
grpc_core::TraceFlagList::Set(strings[i], true);
}
}
@ -144,5 +138,5 @@ void grpc_tracer_init(const char* env_var) {
void grpc_tracer_shutdown(void) {}
int grpc_tracer_set_enabled(const char* name, int enabled) {
return grpc_core::TraceFlagList::Get()->Set(name, enabled != 0);
return grpc_core::TraceFlagList::Set(name, enabled != 0);
}

@ -47,25 +47,19 @@ namespace grpc_core {
class TraceFlag;
class TraceFlagList {
public:
static TraceFlagList* Get();
bool Set(const char* name, bool enabled);
void Add(TraceFlag* flag);
static bool Set(const char* name, bool enabled);
static void Add(TraceFlag* flag);
private:
static TraceFlagList* instance_;
void LogAllTracers();
TraceFlagList() : root_tracer_(nullptr) {}
TraceFlag* root_tracer_;
static void LogAllTracers();
static TraceFlag* root_tracer_;
};
namespace testing {
void grpc_tracer_peer_enable_flag(grpc_core::TraceFlag* flag);
void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag);
}
class TraceFlag {
friend void grpc_core::testing::grpc_tracer_peer_enable_flag(TraceFlag* flag);
friend class TraceFlagList;
public:
TraceFlag(bool default_enabled, const char* name);
~TraceFlag() {}
@ -81,6 +75,9 @@ class TraceFlag {
}
private:
friend void grpc_core::testing::grpc_tracer_enable_flag(TraceFlag* flag);
friend class TraceFlagList;
void set_enabled(bool enabled) {
#ifdef GRPC_THREADSAFE_TRACER
gpr_atm_no_barrier_store(&value_, enabled);

@ -49,8 +49,8 @@ static void add_test(void) {
gpr_log(GPR_INFO, "add_test");
grpc_timer_list_init(&exec_ctx);
grpc_core::testing::grpc_tracer_peer_enable_flag(&grpc_timer_trace);
grpc_core::testing::grpc_tracer_peer_enable_flag(&grpc_timer_check_trace);
grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_trace);
grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_check_trace);
memset(cb_called, 0, sizeof(cb_called));
grpc_millis start = grpc_exec_ctx_now(&exec_ctx);
@ -118,8 +118,8 @@ void destruction_test(void) {
exec_ctx.now_is_valid = true;
exec_ctx.now = 0;
grpc_timer_list_init(&exec_ctx);
grpc_core::testing::grpc_tracer_peer_enable_flag(&grpc_timer_trace);
grpc_core::testing::grpc_tracer_peer_enable_flag(&grpc_timer_check_trace);
grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_trace);
grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_check_trace);
memset(cb_called, 0, sizeof(cb_called));
grpc_timer_init(

@ -137,8 +137,7 @@ static void test_subscribe_with_failure_then_destroy(void) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_core::testing::grpc_tracer_peer_enable_flag(
&grpc_connectivity_state_trace);
grpc_core::testing::grpc_tracer_enable_flag(&grpc_connectivity_state_trace);
test_connectivity_state_name();
test_check();
test_subscribe_then_unsubscribe();

@ -23,7 +23,7 @@
namespace grpc_core {
namespace testing {
void grpc_tracer_peer_enable_flag(grpc_core::TraceFlag* flag) {
void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag) {
flag->set_enabled(1);
}

@ -24,7 +24,7 @@ class TraceFlag;
namespace testing {
// enables the TraceFlag passed to it. Used for testing purposes.
void grpc_tracer_peer_enable_flag(grpc_core::TraceFlag* flag);
void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag);
} // namespace testing
} // namespace grpc_core

Loading…
Cancel
Save