diff --git a/examples/shrpx_downstream.cc b/examples/shrpx_downstream.cc index 48072fb..7f926f1 100644 --- a/examples/shrpx_downstream.cc +++ b/examples/shrpx_downstream.cc @@ -528,7 +528,7 @@ int htp_hdrs_completecb(http_parser *htp) // 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 rtv = { 86400, 0 }; timeval wtv = { 30, 0 }; downstream->get_upstream()->get_client_handler() ->set_upstream_timeouts(&rtv, &wtv); diff --git a/examples/shrpx_downstream_connection.cc b/examples/shrpx_downstream_connection.cc index bf77ef5..3a97af6 100644 --- a/examples/shrpx_downstream_connection.cc +++ b/examples/shrpx_downstream_connection.cc @@ -32,6 +32,12 @@ namespace shrpx { +// Workaround for the inability for Bufferevent to remove timeout from +// bufferevent. Specify this long timeout instead of removing. +namespace { +timeval max_timeout = { 86400, 0 }; +} // namespace + DownstreamConnection::DownstreamConnection(ClientHandler *client_handler) : client_handler_(client_handler), bev_(0), @@ -90,7 +96,7 @@ int DownstreamConnection::attach_downstream(Downstream *downstream) // HTTP request/response model, we first issue request to downstream // server, so just enable write timeout here. bufferevent_set_timeouts(bev_, - 0, + &max_timeout, &get_config()->downstream_write_timeout); return 0; } @@ -106,14 +112,15 @@ void DownstreamConnection::start_waiting_response() if(bev_) { bufferevent_set_timeouts(bev_, &get_config()->downstream_read_timeout, - 0); + &get_config()->downstream_write_timeout); } } void DownstreamConnection::set_tunneling_timeout() { if(bev_) { - bufferevent_set_timeouts(bev_, 0, + bufferevent_set_timeouts(bev_, + &max_timeout, &get_config()->downstream_write_timeout); } } @@ -164,7 +171,7 @@ void DownstreamConnection::detach_downstream(Downstream *downstream) // connection will get EOF from the downstream server and closed. bufferevent_set_timeouts(bev_, &get_config()->downstream_idle_read_timeout, - 0); + &get_config()->downstream_write_timeout); client_handler_->pool_downstream_connection(this); }