summaryrefslogtreecommitdiff
path: root/methods/http.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2017-06-28 13:20:54 +0200
committerJulian Andres Klode <jak@debian.org>2017-06-28 15:52:38 +0200
commitf806530b9ea858ca6bda8fb8f43d988aba02dab3 (patch)
tree23d237b5912c43ff6926c7d7d8e2f134cc90f4b4 /methods/http.cc
parent0fe2161020d6e331639ed11872a947dd20035890 (diff)
methods: http: Drain pending data before selecting
GnuTLS can already have data pending in its buffers, we need to to drain that first otherwise select() might block indefinitely. Gbp-Dch: ignore
Diffstat (limited to 'methods/http.cc')
-rw-r--r--methods/http.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/methods/http.cc b/methods/http.cc
index 4d8c0808b..b302c896d 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -621,7 +621,15 @@ bool HttpServerState::Go(bool ToFile, RequestState &Req)
if (ServerFd->Fd() == -1 && (In.WriteSpace() == false ||
ToFile == false))
return false;
-
+
+ // Handle server IO
+ if (ServerFd->HasPending() && In.ReadSpace() == true)
+ {
+ errno = 0;
+ if (In.Read(ServerFd) == false)
+ return Die(Req);
+ }
+
fd_set rfds,wfds;
FD_ZERO(&rfds);
FD_ZERO(&wfds);