Commit 53a41c95 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Don't call ev_TYPE_set macro while watcher is active

parent c39f2b2c
......@@ -583,14 +583,14 @@ struct ev_loop *ClientHandler::get_loop() const {
}
void ClientHandler::reset_upstream_read_timeout(ev_tstamp t) {
ev_timer_set(&rt_, 0., t);
rt_.repeat = t;
if (ev_is_active(&rt_)) {
ev_timer_again(loop_, &rt_);
}
}
void ClientHandler::reset_upstream_write_timeout(ev_tstamp t) {
ev_timer_set(&wt_, 0., t);
wt_.repeat = t;
if (ev_is_active(&wt_)) {
ev_timer_again(loop_, &wt_);
}
......
......@@ -50,6 +50,10 @@ bool ConnectBlocker::blocked() const { return ev_is_active(&timer_); }
void ConnectBlocker::on_success() { sleep_ = INITIAL_SLEEP; }
void ConnectBlocker::on_failure() {
if (ev_is_active(&timer_)) {
return;
}
sleep_ = std::min(128., sleep_ * 2);
LOG(WARN) << "connect failure, start sleeping " << sleep_;
......
......@@ -385,6 +385,12 @@ int Http2Session::initiate_connection() {
}
}
// rev_ and wev_ could possibly be active here. Since calling
// ev_io_set is not allowed while watcher is active, we have to
// stop them just in case.
ev_io_stop(loop_, &rev_);
ev_io_stop(loop_, &wev_);
ev_io_set(&rev_, fd_, EV_READ);
ev_io_set(&wev_, fd_, EV_WRITE);
......
......@@ -212,8 +212,8 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
ev_set_cb(&rev_, readcb);
ev_timer_set(&rt_, 0., get_config()->downstream_read_timeout);
rt_.repeat = get_config()->downstream_read_timeout;
ev_timer_again(loop_, &rt_);
// TODO we should have timeout for connection establishment
ev_timer_again(loop_, &wt_);
......@@ -424,10 +424,11 @@ void HttpDownstreamConnection::detach_downstream(Downstream *downstream) {
ev_io_start(loop_, &rev_);
ev_io_stop(loop_, &wev_);
ev_set_cb(&rev_, idle_readcb);
ev_timer_stop(loop_, &wt_);
ev_set_cb(&rev_, idle_readcb);
ev_timer_set(&rt_, 0., get_config()->downstream_idle_read_timeout);
rt_.repeat = get_config()->downstream_idle_read_timeout;
ev_set_cb(&rt_, idle_timeoutcb);
ev_timer_again(loop_, &rt_);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment