shrpx: fixed timeout change is not triggered when tunneling.
For upstream timeout, it seems OpenSSL backed bufferevent does not remove timeout. Set large timeout as a workaround.
This commit is contained in:
parent
17699b1fdf
commit
06ed17ff26
|
@ -522,8 +522,26 @@ int htp_hdrs_completecb(http_parser *htp)
|
||||||
downstream->set_response_connection_close(!http_should_keep_alive(htp));
|
downstream->set_response_connection_close(!http_should_keep_alive(htp));
|
||||||
downstream->set_response_state(Downstream::HEADER_COMPLETE);
|
downstream->set_response_state(Downstream::HEADER_COMPLETE);
|
||||||
downstream->get_upstream()->on_downstream_header_complete(downstream);
|
downstream->get_upstream()->on_downstream_header_complete(downstream);
|
||||||
|
|
||||||
|
if(downstream->tunnel_established()) {
|
||||||
|
downstream->get_downstream_connection()->set_tunneling_timeout();
|
||||||
|
// For tunneling, we remove upstream read timeouts. But it seems
|
||||||
|
// libevent cannot remove timeouts for SSL based bufferevent. Set
|
||||||
|
// long timeout here as a workaround.
|
||||||
|
timeval rtv = { 3600*24, 0 };
|
||||||
|
timeval wtv = { 30, 0 };
|
||||||
|
downstream->get_upstream()->get_client_handler()
|
||||||
|
->set_upstream_timeouts(&rtv, &wtv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(downstream->get_request_method() == "HEAD") {
|
||||||
|
// Ignore the response body. HEAD response may contain
|
||||||
|
// Content-Length or Transfer-Encoding: chunked.
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -572,22 +590,11 @@ int htp_msg_completecb(http_parser *htp)
|
||||||
Downstream *downstream;
|
Downstream *downstream;
|
||||||
downstream = reinterpret_cast<Downstream*>(htp->data);
|
downstream = reinterpret_cast<Downstream*>(htp->data);
|
||||||
|
|
||||||
if(downstream->tunnel_established()) {
|
|
||||||
// For tunneling, we remove timeouts.
|
|
||||||
downstream->get_downstream_connection()->remove_timeouts();
|
|
||||||
}
|
|
||||||
|
|
||||||
downstream->set_response_state(Downstream::MSG_COMPLETE);
|
downstream->set_response_state(Downstream::MSG_COMPLETE);
|
||||||
downstream->get_upstream()->on_downstream_body_complete(downstream);
|
downstream->get_upstream()->on_downstream_body_complete(downstream);
|
||||||
|
|
||||||
if(downstream->get_request_method() == "HEAD") {
|
|
||||||
// Ignore the response body. HEAD response may contain
|
|
||||||
// Content-Length or Transfer-Encoding: chunked.
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -110,10 +110,11 @@ void DownstreamConnection::start_waiting_response()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownstreamConnection::remove_timeouts()
|
void DownstreamConnection::set_tunneling_timeout()
|
||||||
{
|
{
|
||||||
if(bev_) {
|
if(bev_) {
|
||||||
bufferevent_set_timeouts(bev_, 0, 0);
|
bufferevent_set_timeouts(bev_, 0,
|
||||||
|
&get_config()->downstream_write_timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
ClientHandler* get_client_handler();
|
ClientHandler* get_client_handler();
|
||||||
Downstream* get_downstream();
|
Downstream* get_downstream();
|
||||||
void start_waiting_response();
|
void start_waiting_response();
|
||||||
void remove_timeouts();
|
void set_tunneling_timeout();
|
||||||
private:
|
private:
|
||||||
ClientHandler *client_handler_;
|
ClientHandler *client_handler_;
|
||||||
bufferevent *bev_;
|
bufferevent *bev_;
|
||||||
|
|
Loading…
Reference in New Issue