connection delay injector: cap delay by deadline (#29349)

pull/29350/head
Mark D. Roth 3 years ago committed by GitHub
parent e53ea89bca
commit 0b79940496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      test/cpp/end2end/connection_delay_injector.cc

@ -51,10 +51,10 @@ class InjectedDelay {
deadline_(deadline) {
memcpy(&address_, addr, sizeof(grpc_resolved_address));
GRPC_CLOSURE_INIT(&timer_callback_, TimerCallback, this, nullptr);
auto duration = g_delay.load();
deadline_ += duration;
grpc_timer_init(&timer_, grpc_core::ExecCtx::Get()->Now() + duration,
&timer_callback_);
grpc_core::Duration duration = g_delay.load();
grpc_core::Timestamp now = grpc_core::ExecCtx::Get()->Now();
duration = std::min(duration, deadline_ - now);
grpc_timer_init(&timer_, now + duration, &timer_callback_);
}
~InjectedDelay() { grpc_channel_args_destroy(channel_args_); }

Loading…
Cancel
Save