From 27d36318b98f3a070fb24557ce691718ef4eec34 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 4 Aug 2020 11:37:45 +0200 Subject: http: Always write to the file if there's something to write We only add the file to the select() call if we have data to write to it prior to the select() call. This is problematic: Assuming we enter Go() with no data to write to the file, but we read some from the server as well as an EOF, we end up not writing it to the file because we did not add the file to the select. We can't always add the file to the select(), because it's basically always ready and we don't want to wake up if we don't have anything to read or write. So for a solution, let's just always write data to the file if there's data to write to it. If some gets leftover, or if some was already present when we started Go(), it will still be added to the select() call and unblock it. Closes: #959518 --- methods/http.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index 9cfc91330..77348d760 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -845,7 +845,8 @@ ResultState HttpServerState::Go(bool ToFile, RequestState &Req) } // Send data to the file - if (FileFD->Fd() != -1 && FD_ISSET(FileFD->Fd(), &wfds)) + if (FileFD->Fd() != -1 && ((In.WriteSpace() == true && ToFile == true) || + FD_ISSET(FileFD->Fd(), &wfds))) { if (In.Write(FileFD) == false) { -- cgit v1.2.3