Merge pull request #18000 from rmstar/timechangetestsan

Fix TSAN flake in time_change_test
pull/18043/head
Vijay Pai 6 years ago committed by GitHub
commit 75bf7c7f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      test/cpp/end2end/time_change_test.cc

@ -74,14 +74,18 @@ static gpr_timespec now_impl(gpr_clock_type clock) {
// offset the value returned by gpr_now(GPR_CLOCK_REALTIME) by msecs // offset the value returned by gpr_now(GPR_CLOCK_REALTIME) by msecs
// milliseconds // milliseconds
static void set_now_offset(int msecs) { static void set_now_offset(int msecs) {
gpr_mu_lock(&g_mu);
g_time_shift_sec = msecs / 1000; g_time_shift_sec = msecs / 1000;
g_time_shift_nsec = (msecs % 1000) * 1e6; g_time_shift_nsec = (msecs % 1000) * 1e6;
gpr_mu_unlock(&g_mu);
} }
// restore the original implementation of gpr_now() // restore the original implementation of gpr_now()
static void reset_now_offset() { static void reset_now_offset() {
gpr_mu_lock(&g_mu);
g_time_shift_sec = 0; g_time_shift_sec = 0;
g_time_shift_nsec = 0; g_time_shift_nsec = 0;
gpr_mu_unlock(&g_mu);
} }
namespace grpc { namespace grpc {

Loading…
Cancel
Save