nghttpx: Limit read rate on upstream-end
This commit is contained in:
parent
aa9688b459
commit
4d51def65f
|
@ -211,6 +211,10 @@ void upstream_http1_connhd_readcb(bufferevent *bev, void *arg)
|
||||||
ClientHandler::ClientHandler(bufferevent *bev, int fd, SSL *ssl,
|
ClientHandler::ClientHandler(bufferevent *bev, int fd, SSL *ssl,
|
||||||
const char *ipaddr)
|
const char *ipaddr)
|
||||||
: bev_(bev),
|
: bev_(bev),
|
||||||
|
evbucket_cfg_(ev_token_bucket_cfg_new(1024*1024, 4*1024*1024,
|
||||||
|
EV_RATE_LIMIT_MAX,
|
||||||
|
EV_RATE_LIMIT_MAX,
|
||||||
|
nullptr)),
|
||||||
fd_(fd),
|
fd_(fd),
|
||||||
ssl_(ssl),
|
ssl_(ssl),
|
||||||
upstream_(nullptr),
|
upstream_(nullptr),
|
||||||
|
@ -219,6 +223,7 @@ ClientHandler::ClientHandler(bufferevent *bev, int fd, SSL *ssl,
|
||||||
spdy_(nullptr),
|
spdy_(nullptr),
|
||||||
left_connhd_len_(NGHTTP2_CLIENT_CONNECTION_HEADER_LEN)
|
left_connhd_len_(NGHTTP2_CLIENT_CONNECTION_HEADER_LEN)
|
||||||
{
|
{
|
||||||
|
bufferevent_set_rate_limit(bev_, evbucket_cfg_);
|
||||||
bufferevent_enable(bev_, EV_READ | EV_WRITE);
|
bufferevent_enable(bev_, EV_READ | EV_WRITE);
|
||||||
bufferevent_setwatermark(bev_, EV_READ, 0, SHRPX_READ_WARTER_MARK);
|
bufferevent_setwatermark(bev_, EV_READ, 0, SHRPX_READ_WARTER_MARK);
|
||||||
set_upstream_timeouts(&get_config()->upstream_read_timeout,
|
set_upstream_timeouts(&get_config()->upstream_read_timeout,
|
||||||
|
@ -244,6 +249,7 @@ ClientHandler::~ClientHandler()
|
||||||
}
|
}
|
||||||
bufferevent_disable(bev_, EV_READ | EV_WRITE);
|
bufferevent_disable(bev_, EV_READ | EV_WRITE);
|
||||||
bufferevent_free(bev_);
|
bufferevent_free(bev_);
|
||||||
|
ev_token_bucket_cfg_free(evbucket_cfg_);
|
||||||
if(ssl_) {
|
if(ssl_) {
|
||||||
SSL_free(ssl_);
|
SSL_free(ssl_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
bool get_http2_upgrade_allowed() const;
|
bool get_http2_upgrade_allowed() const;
|
||||||
private:
|
private:
|
||||||
bufferevent *bev_;
|
bufferevent *bev_;
|
||||||
|
ev_token_bucket_cfg *evbucket_cfg_;
|
||||||
int fd_;
|
int fd_;
|
||||||
SSL *ssl_;
|
SSL *ssl_;
|
||||||
Upstream *upstream_;
|
Upstream *upstream_;
|
||||||
|
|
Loading…
Reference in New Issue