nghttpx: Don't enable read timer while connecting to HTTP/1 server

This commit is contained in:
Tatsuhiro Tsujikawa 2015-07-27 01:18:52 +09:00
parent 90b4b48c7e
commit efcd43a367
1 changed files with 15 additions and 15 deletions

View File

@ -189,6 +189,15 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
break; break;
} }
// TODO we should have timeout for connection establishment
ev_timer_again(conn_.loop, &conn_.wt);
} else {
// we may set read timer cb to idle_timeoutcb. Reset again.
conn_.rt.repeat = get_config()->downstream_read_timeout;
ev_set_cb(&conn_.rt, timeoutcb);
ev_timer_again(conn_.loop, &conn_.rt);
ev_set_cb(&conn_.rev, readcb);
} }
downstream_ = downstream; downstream_ = downstream;
@ -196,15 +205,6 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
http_parser_init(&response_htp_, HTTP_RESPONSE); http_parser_init(&response_htp_, HTTP_RESPONSE);
response_htp_.data = downstream_; response_htp_.data = downstream_;
ev_set_cb(&conn_.rev, readcb);
conn_.rt.repeat = get_config()->downstream_read_timeout;
// we may set read timer cb to idle_timeoutcb. Reset again.
ev_set_cb(&conn_.rt, timeoutcb);
ev_timer_again(conn_.loop, &conn_.rt);
// TODO we should have timeout for connection establishment
ev_timer_again(conn_.loop, &conn_.wt);
return 0; return 0;
} }
@ -472,18 +472,16 @@ void HttpDownstreamConnection::detach_downstream(Downstream *downstream) {
DCLOG(INFO, this) << "Detaching from DOWNSTREAM:" << downstream; DCLOG(INFO, this) << "Detaching from DOWNSTREAM:" << downstream;
} }
downstream_ = nullptr; downstream_ = nullptr;
ioctrl_.force_resume_read();
conn_.rlimit.startw();
conn_.wlimit.stopw();
ev_set_cb(&conn_.rev, idle_readcb); ev_set_cb(&conn_.rev, idle_readcb);
ioctrl_.force_resume_read();
ev_timer_stop(conn_.loop, &conn_.wt);
conn_.rt.repeat = get_config()->downstream_idle_read_timeout; conn_.rt.repeat = get_config()->downstream_idle_read_timeout;
ev_set_cb(&conn_.rt, idle_timeoutcb); ev_set_cb(&conn_.rt, idle_timeoutcb);
ev_timer_again(conn_.loop, &conn_.rt); ev_timer_again(conn_.loop, &conn_.rt);
conn_.wlimit.stopw();
ev_timer_stop(conn_.loop, &conn_.wt);
} }
void HttpDownstreamConnection::pause_read(IOCtrlReason reason) { void HttpDownstreamConnection::pause_read(IOCtrlReason reason) {
@ -870,6 +868,8 @@ int HttpDownstreamConnection::on_connect() {
connect_blocker->on_success(); connect_blocker->on_success();
conn_.rlimit.startw(); conn_.rlimit.startw();
ev_timer_again(conn_.loop, &conn_.rt);
ev_set_cb(&conn_.wev, writecb); ev_set_cb(&conn_.wev, writecb);
return 0; return 0;