#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/promise/activity.h"
+#include "src/core/lib/promise/context.h"
#include "src/core/lib/promise/for_each.h"
#include "src/core/lib/promise/if.h"
#include "src/core/lib/promise/loop.h"
}
return absl::OkStatus();
}));
+ },
+ [self = RefAsSubclass<Http2ClientTransport>()]() -> Poll<absl::Status> {
+ if (self->should_stall_read_loop_) {
+ self->read_loop_waker_ = GetContext<Activity>()->MakeNonOwningWaker();
+ return Pending{};
+ }
+ return absl::OkStatus();
}));
}
/*enable_preferred_rx_crypto_frame_advertisement=*/true);
if (action.AnyUpdateImmediately()) {
+ // Prioritize sending flow control updates over reading data. If we
+ // continue reading while urgent flow control updates are pending, we might
+ // exhaust the flow control window. This prevents us from sending window
+ // updates to the peer, causing the peer to block unnecessarily while
+ // waiting for flow control tokens.
+ should_stall_read_loop_ = true;
SpawnGuardedTransportParty("SendControlFrames", TriggerWriteCycle());
}
}
// Notify Control modules that we have sent the frames.
// All notifications are expected to be synchronous.
GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport NotifyControlFramesWriteDone";
+ if (should_stall_read_loop_) {
+ should_stall_read_loop_ = false;
+ read_loop_waker_.Wakeup();
+ }
ping_manager_.NotifyPingSent(ping_timeout_);
goaway_manager_.NotifyGoawaySent();
}
"PH2_Client",
channel_args.GetBool(GRPC_ARG_HTTP2_BDP_PROBE).value_or(true),
&memory_owner_),
- ztrace_collector_(std::make_shared<PromiseHttp2ZTraceCollector>()) {
+ ztrace_collector_(std::make_shared<PromiseHttp2ZTraceCollector>()),
+ should_stall_read_loop_(false) {
GRPC_HTTP2_CLIENT_DLOG << "Http2ClientTransport Constructor Begin";
SourceConstructed();
// TODO(tjagtap) [PH2][P2][BDP] Remove this when the BDP code is done.
Waker periodic_updates_waker_;
+
+ // TODO(tjagtap) [PH2][P2][Settings] Set this to true when we receive settings
+ // that appear "Urgent". Example - initial window size 0 is urgent because it
+ // indicates extreme memory pressure on the server.
+ bool should_stall_read_loop_;
+ Waker read_loop_waker_;
};
// Since the corresponding class in CHTTP2 is about 3.9KB, our goal is to