Commit fd2eafa7 authored by Max Kellermann's avatar Max Kellermann

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.
parent 422b8472
ver 0.18.2 (2013/??/??) ver 0.18.2 (2013/??/??)
* protocol:
- "close" flushes the output buffer
* input: * input:
- curl: fix bug with redirected streams - curl: fix bug with redirected streams
* playlist: * playlist:
......
...@@ -57,6 +57,11 @@ Client::OnSocketInput(void *data, size_t length) ...@@ -57,6 +57,11 @@ Client::OnSocketInput(void *data, size_t length)
main_loop->Break(); main_loop->Break();
return InputResult::CLOSED; return InputResult::CLOSED;
case CommandResult::FINISH:
if (Flush())
Close();
return InputResult::CLOSED;
case CommandResult::CLOSE: case CommandResult::CLOSE:
Close(); Close();
return InputResult::CLOSED; return InputResult::CLOSED;
......
...@@ -48,6 +48,12 @@ enum class CommandResult { ...@@ -48,6 +48,12 @@ enum class CommandResult {
ERROR, 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. * The connection to this client shall be closed.
*/ */
CLOSE, CLOSE,
......
...@@ -99,7 +99,7 @@ CommandResult ...@@ -99,7 +99,7 @@ CommandResult
handle_close(gcc_unused Client &client, handle_close(gcc_unused Client &client,
gcc_unused int argc, gcc_unused char *argv[]) gcc_unused int argc, gcc_unused char *argv[])
{ {
return CommandResult::CLOSE; return CommandResult::FINISH;
} }
CommandResult CommandResult
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment