88
99#include < proxygen/lib/transport/qmux/QmuxConnector.h>
1010
11+ #include < chrono>
1112#include < cstdint>
1213#include < fmt/core.h>
13- #include < folly/coro/Timeout.h>
14- #include < folly/futures/ThreadWheelTimekeeper.h>
1514#include < folly/io/Cursor.h>
1615#include < folly/io/IOBufQueue.h>
1716#include < folly/logging/xlog.h>
@@ -148,12 +147,21 @@ folly::coro::Task<QxTransportParams> readPeerTransportParams(
148147 QmuxTransport& transport,
149148 folly::IOBufQueue& ingressBuf,
150149 std::chrono::milliseconds timeout) {
150+ const auto deadline = std::chrono::steady_clock::now () + timeout;
151151 while (true ) {
152+ const auto remaining =
153+ std::chrono::duration_cast<std::chrono::milliseconds>(
154+ deadline - std::chrono::steady_clock::now ());
155+ if (remaining <= std::chrono::milliseconds::zero ()) {
156+ co_yield co_error (
157+ std::runtime_error (" timed out waiting for QX_TRANSPORT_PARAMETERS" ));
158+ }
159+
152160 auto readRes = co_await folly::coro::co_awaitTry (
153161 transport.read (ingressBuf,
154162 /* minReadSize=*/ 1 ,
155163 /* newAllocationSize=*/ 4096 ,
156- timeout ));
164+ remaining ));
157165 if (readRes.hasException ()) {
158166 co_yield co_error (readRes.exception ());
159167 }
@@ -194,7 +202,7 @@ WtStreamManager::WtConfig makeWtConfig(
194202}
195203
196204folly::coro::Task<QmuxSession::Ptr> QmuxConnector::connect (
197- folly::EventBase* evb ,
205+ std::shared_ptr<quic::QuicExecutor> executor ,
198206 WtDir dir,
199207 QxTransportParams selfParams,
200208 std::unique_ptr<QmuxTransport> transport,
@@ -220,10 +228,9 @@ folly::coro::Task<QmuxSession::Ptr> QmuxConnector::connect(
220228 // timeout. peelTransportParams trims the TP frame and rewraps any
221229 // same-record trailing bytes so they parse cleanly downstream.
222230 folly::IOBufQueue ingressBuf{folly::IOBufQueue::cacheChainLength ()};
223- folly::EventBaseThreadTimekeeper tk{*evb};
224231
225- auto peerParams = co_await folly::coro::co_awaitTry (folly::coro::timeout (
226- readPeerTransportParams (*transport, ingressBuf, timeout), timeout, &tk) );
232+ auto peerParams = co_await folly::coro::co_awaitTry (
233+ readPeerTransportParams (*transport, ingressBuf, timeout));
227234 if (peerParams.hasException ()) {
228235 XLOG (ERR ) << " QmuxConnector: TP read failed: " << peerParams.exception ();
229236 co_yield co_error (peerParams.exception ());
@@ -246,7 +253,7 @@ folly::coro::Task<QmuxSession::Ptr> QmuxConnector::connect(
246253 effectiveMaxIdleTimeoutMs = peerParams->maxIdleTimeout ;
247254 }
248255
249- co_return std::make_shared<QmuxSession>(evb ,
256+ co_return std::make_shared<QmuxSession>(std::move (executor) ,
250257 dir,
251258 std::move (selfParams),
252259 std::move (transport),
0 commit comments