diff --git a/src/HttpServer.cc b/src/HttpServer.cc index ee07845..4545922 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -614,6 +614,7 @@ int Http2Handler::read_clear() { } return -1; } + break; } return write_(*this); @@ -739,6 +740,7 @@ int Http2Handler::read_tls() { } return -1; } + break; } fin: diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc index ed161db..b8dbd3c 100644 --- a/src/shrpx_client_handler.cc +++ b/src/shrpx_client_handler.cc @@ -114,6 +114,7 @@ void writecb(struct ev_loop *loop, ev_io *w, int revents) { int ClientHandler::noop() { return 0; } int ClientHandler::read_clear() { + auto should_break = false; ev_timer_again(conn_.loop, &conn_.rt); for (;;) { @@ -126,6 +127,10 @@ int ClientHandler::read_clear() { conn_.rlimit.stopw(); return 0; } + + if (should_break) { + return 0; + } auto nread = conn_.read_clear(rb_.last, rb_.wleft()); @@ -138,6 +143,7 @@ int ClientHandler::read_clear() { } rb_.write(nread); + should_break = true; } } @@ -204,6 +210,7 @@ int ClientHandler::tls_handshake() { } int ClientHandler::read_tls() { + auto should_break = false; ev_timer_again(conn_.loop, &conn_.rt); ERR_clear_error(); @@ -219,6 +226,10 @@ int ClientHandler::read_tls() { conn_.rlimit.stopw(); return 0; } + + if (should_break) { + return 0; + } auto nread = conn_.read_tls(rb_.last, rb_.wleft()); @@ -231,6 +242,7 @@ int ClientHandler::read_tls() { } rb_.write(nread); + should_break = true; } }