shrpx: Specify long enough timeout to emulate removing timeout
It seems that specifying NULL to bufferevent_set_timeouts() does not remove timeout, which is described in bufferevent book (but it is not described in header). As a workaround, we specify long enough timeout to emulate removing timeout.
This commit is contained in:
parent
d36f9f1c5b
commit
2afc50bf49
|
@ -528,7 +528,7 @@ int htp_hdrs_completecb(http_parser *htp)
|
||||||
// For tunneling, we remove upstream read timeouts. But it seems
|
// For tunneling, we remove upstream read timeouts. But it seems
|
||||||
// libevent cannot remove timeouts for SSL based bufferevent. Set
|
// libevent cannot remove timeouts for SSL based bufferevent. Set
|
||||||
// long timeout here as a workaround.
|
// long timeout here as a workaround.
|
||||||
timeval rtv = { 3600*24, 0 };
|
timeval rtv = { 86400, 0 };
|
||||||
timeval wtv = { 30, 0 };
|
timeval wtv = { 30, 0 };
|
||||||
downstream->get_upstream()->get_client_handler()
|
downstream->get_upstream()->get_client_handler()
|
||||||
->set_upstream_timeouts(&rtv, &wtv);
|
->set_upstream_timeouts(&rtv, &wtv);
|
||||||
|
|
|
@ -32,6 +32,12 @@
|
||||||
|
|
||||||
namespace shrpx {
|
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)
|
DownstreamConnection::DownstreamConnection(ClientHandler *client_handler)
|
||||||
: client_handler_(client_handler),
|
: client_handler_(client_handler),
|
||||||
bev_(0),
|
bev_(0),
|
||||||
|
@ -90,7 +96,7 @@ int DownstreamConnection::attach_downstream(Downstream *downstream)
|
||||||
// HTTP request/response model, we first issue request to downstream
|
// HTTP request/response model, we first issue request to downstream
|
||||||
// server, so just enable write timeout here.
|
// server, so just enable write timeout here.
|
||||||
bufferevent_set_timeouts(bev_,
|
bufferevent_set_timeouts(bev_,
|
||||||
0,
|
&max_timeout,
|
||||||
&get_config()->downstream_write_timeout);
|
&get_config()->downstream_write_timeout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -106,14 +112,15 @@ void DownstreamConnection::start_waiting_response()
|
||||||
if(bev_) {
|
if(bev_) {
|
||||||
bufferevent_set_timeouts(bev_,
|
bufferevent_set_timeouts(bev_,
|
||||||
&get_config()->downstream_read_timeout,
|
&get_config()->downstream_read_timeout,
|
||||||
0);
|
&get_config()->downstream_write_timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownstreamConnection::set_tunneling_timeout()
|
void DownstreamConnection::set_tunneling_timeout()
|
||||||
{
|
{
|
||||||
if(bev_) {
|
if(bev_) {
|
||||||
bufferevent_set_timeouts(bev_, 0,
|
bufferevent_set_timeouts(bev_,
|
||||||
|
&max_timeout,
|
||||||
&get_config()->downstream_write_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.
|
// connection will get EOF from the downstream server and closed.
|
||||||
bufferevent_set_timeouts(bev_,
|
bufferevent_set_timeouts(bev_,
|
||||||
&get_config()->downstream_idle_read_timeout,
|
&get_config()->downstream_idle_read_timeout,
|
||||||
0);
|
&get_config()->downstream_write_timeout);
|
||||||
client_handler_->pool_downstream_connection(this);
|
client_handler_->pool_downstream_connection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue