Commit 83d362c6 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Don't read too greedily

parent a76d0723
...@@ -650,6 +650,7 @@ int Http2Handler::read_clear() { ...@@ -650,6 +650,7 @@ int Http2Handler::read_clear() {
} }
return -1; return -1;
} }
break;
} }
return write_(*this); return write_(*this);
...@@ -775,6 +776,7 @@ int Http2Handler::read_tls() { ...@@ -775,6 +776,7 @@ int Http2Handler::read_tls() {
} }
return -1; return -1;
} }
break;
} }
fin: fin:
......
...@@ -111,6 +111,7 @@ void writecb(struct ev_loop *loop, ev_io *w, int revents) { ...@@ -111,6 +111,7 @@ void writecb(struct ev_loop *loop, ev_io *w, int revents) {
int ClientHandler::noop() { return 0; } int ClientHandler::noop() { return 0; }
int ClientHandler::read_clear() { int ClientHandler::read_clear() {
auto should_break = false;
rb_.ensure_chunk(); rb_.ensure_chunk();
for (;;) { for (;;) {
if (rb_.rleft() && on_read() != 0) { if (rb_.rleft() && on_read() != 0) {
...@@ -123,7 +124,7 @@ int ClientHandler::read_clear() { ...@@ -123,7 +124,7 @@ int ClientHandler::read_clear() {
return 0; return 0;
} }
if (!ev_is_active(&conn_.rev)) { if (!ev_is_active(&conn_.rev) || should_break) {
return 0; return 0;
} }
...@@ -141,6 +142,7 @@ int ClientHandler::read_clear() { ...@@ -141,6 +142,7 @@ int ClientHandler::read_clear() {
} }
rb_.write(nread); rb_.write(nread);
should_break = true;
} }
} }
...@@ -205,6 +207,8 @@ int ClientHandler::tls_handshake() { ...@@ -205,6 +207,8 @@ int ClientHandler::tls_handshake() {
} }
int ClientHandler::read_tls() { int ClientHandler::read_tls() {
auto should_break = false;
ERR_clear_error(); ERR_clear_error();
rb_.ensure_chunk(); rb_.ensure_chunk();
...@@ -221,7 +225,7 @@ int ClientHandler::read_tls() { ...@@ -221,7 +225,7 @@ int ClientHandler::read_tls() {
return 0; return 0;
} }
if (!ev_is_active(&conn_.rev)) { if (!ev_is_active(&conn_.rev) || should_break) {
return 0; return 0;
} }
...@@ -239,6 +243,7 @@ int ClientHandler::read_tls() { ...@@ -239,6 +243,7 @@ int ClientHandler::read_tls() {
} }
rb_.write(nread); rb_.write(nread);
should_break = true;
} }
} }
......
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