nghttpx: Faster HTTP/1 frontend

This commit is contained in:
Tatsuhiro Tsujikawa 2016-11-29 20:42:27 +09:00
parent bdd3425028
commit ff64f64e1d
3 changed files with 15 additions and 9 deletions

View File

@ -1278,6 +1278,10 @@ ClientHandler::ReadBuf *ClientHandler::get_rb() { return &rb_; }
void ClientHandler::signal_write() { conn_.wlimit.startw(); }
void ClientHandler::signal_write_no_wait() {
ev_feed_event(conn_.loop, &conn_.wev, EV_WRITE);
}
RateLimit *ClientHandler::get_rlimit() { return &conn_.rlimit; }
RateLimit *ClientHandler::get_wlimit() { return &conn_.wlimit; }

View File

@ -132,6 +132,8 @@ public:
RateLimit *get_wlimit();
void signal_write();
// Use this for HTTP/1 frontend since it produces better result.
void signal_write_no_wait();
ev_io *get_wev();
void setup_upstream_io_callback();

View File

@ -431,7 +431,7 @@ int htp_hdrs_completecb(http_parser *htp) {
auto output = downstream->get_response_buf();
constexpr auto res = StringRef::from_lit("HTTP/1.1 100 Continue\r\n\r\n");
output->append(res);
handler->signal_write();
handler->signal_write_no_wait();
}
}
@ -477,7 +477,7 @@ int htp_msg_completecb(http_parser *htp) {
// in request phase hook. We only delete and proceed to the
// next request handling (if we don't close the connection). We
// first pause parser here just as we normally do, and call
// signal_write() to run on_write().
// signal_write_no_wait() to run on_write().
http_parser_pause(htp, 1);
return 0;
@ -581,7 +581,7 @@ int HttpsUpstream::on_read() {
if (downstream &&
downstream->get_request_state() == Downstream::MSG_COMPLETE &&
downstream->get_response_state() == Downstream::MSG_COMPLETE) {
handler_->signal_write();
handler_->signal_write_no_wait();
}
return 0;
}
@ -595,7 +595,7 @@ int HttpsUpstream::on_read() {
if (downstream && downstream->get_response_state() != Downstream::INITIAL) {
handler_->set_should_close_after_write(true);
handler_->signal_write();
handler_->signal_write_no_wait();
return 0;
}
@ -621,7 +621,7 @@ int HttpsUpstream::on_read() {
error_reply(status_code);
handler_->signal_write();
handler_->signal_write_no_wait();
return 0;
}
@ -740,7 +740,7 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) {
}
end:
handler_->signal_write();
handler_->signal_write_no_wait();
return 0;
}
@ -797,7 +797,7 @@ int HttpsUpstream::downstream_eof(DownstreamConnection *dconn) {
// drop connection.
return -1;
end:
handler_->signal_write();
handler_->signal_write_no_wait();
return 0;
}
@ -825,7 +825,7 @@ int HttpsUpstream::downstream_error(DownstreamConnection *dconn, int events) {
downstream->pop_downstream_connection();
handler_->signal_write();
handler_->signal_write_no_wait();
return 0;
}
@ -1194,7 +1194,7 @@ int HttpsUpstream::on_downstream_body_complete(Downstream *downstream) {
int HttpsUpstream::on_downstream_abort_request(Downstream *downstream,
unsigned int status_code) {
error_reply(status_code);
handler_->signal_write();
handler_->signal_write_no_wait();
return 0;
}