From d1391f1db71aa55dac450da61e4402776c2d478f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 6 Jan 2015 22:48:17 +0900 Subject: [PATCH] nghttpx: Process buffered data first without reading additional data --- src/shrpx_client_handler.cc | 9 ++++++++- src/shrpx_http2_session.cc | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc index 538ae876..c00b534e 100644 --- a/src/shrpx_client_handler.cc +++ b/src/shrpx_client_handler.cc @@ -97,9 +97,13 @@ int ClientHandler::read_clear() { ev_timer_again(loop_, &rt_); for (;;) { + // we should process buffered data first before we read EOF. if (rb_.rleft() && on_read() != 0) { return -1; } + if (rb_.rleft()) { + return 0; + } rb_.reset(); struct iovec iov[2]; auto iovcnt = rb_.wiovec(iov); @@ -222,10 +226,13 @@ int ClientHandler::read_tls() { ev_timer_again(loop_, &rt_); for (;;) { + // we should process buffered data first before we read EOF. if (rb_.rleft() && on_read() != 0) { return -1; } - + if (rb_.rleft()) { + return 0; + } rb_.reset(); struct iovec iov[2]; auto iovcnt = rb_.wiovec(iov); diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 83c75331..59116b81 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -1537,9 +1537,13 @@ int Http2Session::read_clear() { ev_timer_again(loop_, &rt_); for (;;) { + // we should process buffered data first before we read EOF. if (rb_.rleft() && on_read() != 0) { return -1; } + if (rb_.rleft()) { + return 0; + } rb_.reset(); struct iovec iov[2]; auto iovcnt = rb_.wiovec(iov); @@ -1661,10 +1665,13 @@ int Http2Session::read_tls() { ev_timer_again(loop_, &rt_); for (;;) { + // we should process buffered data first before we read EOF. if (rb_.rleft() && on_read() != 0) { return -1; } - + if (rb_.rleft()) { + return 0; + } rb_.reset(); struct iovec iov[2]; auto iovcnt = rb_.wiovec(iov);