diff options
author | Max Kellermann <max@duempel.org> | 2013-11-06 22:01:06 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-06 22:01:06 +0100 |
commit | fd2eafa7c67e0efdae7d3d18c39b97f724372f7e (patch) | |
tree | 391bc672c8ec24a728a163ce9ed8026287d0f039 | |
parent | 422b8472fec9443250895a281b6b0a20190daa22 (diff) |
ClientRead: "close" flushes the output buffer
Add a new CommandResult code called "FINISH" which, unlike "CLOSE",
will attempt to flush the output buffer. This is a one-shot attempt;
it will do one write, and not try again.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/ClientRead.cxx | 5 | ||||
-rw-r--r-- | src/command/CommandResult.hxx | 6 | ||||
-rw-r--r-- | src/command/OtherCommands.cxx | 2 |
4 files changed, 14 insertions, 1 deletions
@@ -1,4 +1,6 @@ ver 0.18.2 (2013/??/??) +* protocol: + - "close" flushes the output buffer * input: - curl: fix bug with redirected streams * playlist: diff --git a/src/ClientRead.cxx b/src/ClientRead.cxx index 925e1502d..22edefe60 100644 --- a/src/ClientRead.cxx +++ b/src/ClientRead.cxx @@ -57,6 +57,11 @@ Client::OnSocketInput(void *data, size_t length) main_loop->Break(); return InputResult::CLOSED; + case CommandResult::FINISH: + if (Flush()) + Close(); + return InputResult::CLOSED; + case CommandResult::CLOSE: Close(); return InputResult::CLOSED; diff --git a/src/command/CommandResult.hxx b/src/command/CommandResult.hxx index bbc16146b..9916b70cb 100644 --- a/src/command/CommandResult.hxx +++ b/src/command/CommandResult.hxx @@ -48,6 +48,12 @@ enum class CommandResult { ERROR, /** + * The client has asked MPD to close the connection. MPD will + * flush the remaining output buffer first. + */ + FINISH, + + /** * The connection to this client shall be closed. */ CLOSE, diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx index 75faa4dc2..7b2cb1331 100644 --- a/src/command/OtherCommands.cxx +++ b/src/command/OtherCommands.cxx @@ -99,7 +99,7 @@ CommandResult handle_close(gcc_unused Client &client, gcc_unused int argc, gcc_unused char *argv[]) { - return CommandResult::CLOSE; + return CommandResult::FINISH; } CommandResult |