Skip to content

Commit f897723

Browse files
committed
Fix client fetch w/connect proxy reporting cancellation on timeout.
1 parent 1953102 commit f897723

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/client.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,17 +1038,17 @@ Session Client::State::fetch_fresh_from_origin( Request rq
10381038

10391039
//------------------------------------------------------------------------------
10401040
Session Client::State::fetch_fresh_through_connect_proxy( const Request& rq
1041-
, Cancel& cancel_
1041+
, Cancel& cancel
10421042
, Yield yield)
10431043
{
10441044
// TODO: We're not re-using connections here. It's because the
10451045
// ConnectionPool as it is right now can only work with http requests
10461046
// and responses and thus can't be used for full-dupplex forwarding.
10471047

1048-
Cancel cancel(cancel_);
1048+
Cancel timeout_cancel(cancel);
10491049
auto watch_dog = ouinet::watch_dog( _ctx
10501050
, default_timeout::fetch_http()
1051-
, [&]{ cancel(); });
1051+
, [&]{ timeout_cancel(); });
10521052

10531053
// Parse the URL to tell HTTP/HTTPS, host, port.
10541054
util::url_match url;
@@ -1061,12 +1061,12 @@ Session Client::State::fetch_fresh_through_connect_proxy( const Request& rq
10611061
// Connect to the injector/proxy.
10621062
sys::error_code ec;
10631063

1064-
wait_for_injector(cancel, yield[ec]);
1064+
wait_for_injector(timeout_cancel, yield[ec]);
10651065
fail_on_error_or_timeout(yield, cancel, ec, watch_dog, Session{});
10661066
assert(_injector);
10671067

10681068
auto inj = yield[ec].tag("connect_to_injector").run([&] (auto y) {
1069-
return _injector->connect(y, cancel);
1069+
return _injector->connect(y, timeout_cancel);
10701070
});
10711071
fail_on_error_or_timeout(yield, cancel, ec, watch_dog, Session{});
10721072

@@ -1085,7 +1085,7 @@ Session Client::State::fetch_fresh_through_connect_proxy( const Request& rq
10851085
// Open a tunnel to the origin
10861086
// (to later perform the SSL handshake and send the request).
10871087
yield[ec].tag("connreq").run([&] (auto y) {
1088-
util::http_request(inj.connection, connreq, cancel, y);
1088+
util::http_request(inj.connection, connreq, timeout_cancel, y);
10891089
});
10901090
fail_on_error_or_timeout(yield, cancel, ec, watch_dog, Session{});
10911091

@@ -1097,7 +1097,7 @@ Session Client::State::fetch_fresh_through_connect_proxy( const Request& rq
10971097
auto r = std::make_unique<http_response::Reader>(std::move(inj.connection));
10981098

10991099
auto part = yield[ec].tag("read_hdr").run([&] (auto y) {
1100-
return r->async_read_part(cancel, y);
1100+
return r->async_read_part(timeout_cancel, y);
11011101
});
11021102
fail_on_error_or_timeout(yield, cancel, ec, watch_dog, Session{});
11031103
assert(part && part->is_head());
@@ -1121,7 +1121,7 @@ Session Client::State::fetch_fresh_through_connect_proxy( const Request& rq
11211121
con = ssl::util::client_handshake( move(inj.connection)
11221122
, ssl_ctx
11231123
, url.host
1124-
, cancel
1124+
, timeout_cancel
11251125
, static_cast<asio::yield_context>(yield[ec]));
11261126
} else {
11271127
con = move(inj.connection);
@@ -1132,14 +1132,14 @@ Session Client::State::fetch_fresh_through_connect_proxy( const Request& rq
11321132
auto rq_ = util::req_form_from_absolute_to_origin(rq);
11331133

11341134
yield[ec].tag("write_req").run([&] (auto y) {
1135-
auto slot = cancel.connect([&con] { con.close(); });
1135+
auto slot = timeout_cancel.connect([&con] { con.close(); });
11361136
http::async_write(con, rq_, y);
11371137
});
11381138
fail_on_error_or_timeout(yield, cancel, ec, watch_dog, Session{});
11391139

11401140
auto session = yield[ec].tag("read_hdr").run([&] (auto y) {
11411141
return Session::create( move(con), rq.method() == http::verb::head
1142-
, cancel, y);
1142+
, timeout_cancel, y);
11431143
});
11441144
fail_on_error_or_timeout(yield, cancel, ec, watch_dog, Session{});
11451145

0 commit comments

Comments
 (0)