summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-08-04 11:37:45 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2020-08-04 11:46:39 +0200
commit27d36318b98f3a070fb24557ce691718ef4eec34 (patch)
tree34f2dd54098349f39eb8527c8e78042055fe417f /methods
parent4d5a389dfc2cda5c82876fefdb9dd283e013f827 (diff)
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
Diffstat (limited to 'methods')
-rw-r--r--methods/http.cc3
1 files changed, 2 insertions, 1 deletions
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)
{