diff options
author | Max Kellermann <max@musicpd.org> | 2019-04-03 22:31:49 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-04-03 22:31:49 +0200 |
commit | 7d1db5c19f86b431e5614506576fc45f3a075a6b (patch) | |
tree | 51eae872f5e782d193caf987cd99b2ff3bb328dd /src/client | |
parent | 2142d070a35bfca1464d1c7f3b3ab7eba9b9addc (diff) |
client/Process: refactor IsExpired() checks
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/Process.cxx | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/client/Process.cxx b/src/client/Process.cxx index b62a549b1..cf6ed885b 100644 --- a/src/client/Process.cxx +++ b/src/client/Process.cxx @@ -34,22 +34,23 @@ inline CommandResult Client::ProcessCommandList(bool list_ok, std::list<std::string> &&list) noexcept { - CommandResult ret = CommandResult::OK; unsigned n = 0; for (auto &&i : list) { char *cmd = &*i.begin(); FormatDebug(client_domain, "process command \"%s\"", cmd); - ret = command_process(*this, n++, cmd); + auto ret = command_process(*this, n++, cmd); FormatDebug(client_domain, "command returned %i", int(ret)); - if (ret != CommandResult::OK || IsExpired()) - break; + if (IsExpired()) + return CommandResult::CLOSE; + else if (ret != CommandResult::OK) + return ret; else if (list_ok) Write("list_OK\n"); } - return ret; + return CommandResult::OK; } CommandResult @@ -100,10 +101,11 @@ Client::ProcessLine(char *line) noexcept "[%u] process command " "list returned %i", num, int(ret)); - if (ret == CommandResult::CLOSE || - IsExpired()) + if (ret == CommandResult::CLOSE) return CommandResult::CLOSE; + assert(!IsExpired()); + if (ret == CommandResult::OK) command_success(*this); @@ -138,7 +140,7 @@ Client::ProcessLine(char *line) noexcept "[%u] command returned %i", num, int(ret)); - if (ret == CommandResult::CLOSE || IsExpired()) + if (IsExpired()) return CommandResult::CLOSE; if (ret == CommandResult::OK) |