diff options
author | Max Kellermann <max@duempel.org> | 2013-01-04 00:50:13 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-04 00:50:13 +0100 |
commit | fb337418a5b8d85306c96ad51d445fd58fb38491 (patch) | |
tree | b2ffd1c9f18bb643238741b72538d1ee5a5a4f8e /src/ClientProcess.cxx | |
parent | 9d312ab208f797a69c8366f4a961d6cb3228cecb (diff) | |
download | mpd-fb337418a5b8d85306c96ad51d445fd58fb38491.tar.gz mpd-fb337418a5b8d85306c96ad51d445fd58fb38491.tar.xz mpd-fb337418a5b8d85306c96ad51d445fd58fb38491.zip |
Client: move code to class CommandListBuilder
Diffstat (limited to 'src/ClientProcess.cxx')
-rw-r--r-- | src/ClientProcess.cxx | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/ClientProcess.cxx b/src/ClientProcess.cxx index bbc19321e..9d3716029 100644 --- a/src/ClientProcess.cxx +++ b/src/ClientProcess.cxx @@ -76,19 +76,16 @@ client_process_line(Client *client, char *line) return COMMAND_RETURN_CLOSE; } - if (client->cmd_list_OK >= 0) { + if (client->cmd_list.IsActive()) { if (strcmp(line, CLIENT_LIST_MODE_END) == 0) { g_debug("[%u] process command list", client->num); - /* for scalability reasons, we have prepended - each new command; now we have to reverse it - to restore the correct order */ - client->cmd_list = g_slist_reverse(client->cmd_list); + auto cmd_list = client->cmd_list.Commit(); ret = client_process_command_list(client, - client->cmd_list_OK, - client->cmd_list); + client->cmd_list.IsOKMode(), + cmd_list); g_debug("[%u] process command " "list returned %i", client->num, ret); @@ -100,31 +97,24 @@ client_process_line(Client *client, char *line) command_success(client); client_write_output(client); - free_cmd_list(client->cmd_list); - client->cmd_list = NULL; - client->cmd_list_OK = -1; + client->cmd_list.Reset(); } else { - size_t len = strlen(line) + 1; - client->cmd_list_size += len; - if (client->cmd_list_size > - client_max_command_list_size) { - g_warning("[%u] command list size (%lu) " + if (!client->cmd_list.Add(line)) { + g_warning("[%u] command list size " "is larger than the max (%lu)", client->num, - (unsigned long)client->cmd_list_size, (unsigned long)client_max_command_list_size); return COMMAND_RETURN_CLOSE; } - new_cmd_list_ptr(client, line); ret = COMMAND_RETURN_OK; } } else { if (strcmp(line, CLIENT_LIST_MODE_BEGIN) == 0) { - client->cmd_list_OK = 0; + client->cmd_list.Begin(false); ret = COMMAND_RETURN_OK; } else if (strcmp(line, CLIENT_LIST_OK_MODE_BEGIN) == 0) { - client->cmd_list_OK = 1; + client->cmd_list.Begin(true); ret = COMMAND_RETURN_OK; } else { g_debug("[%u] process command \"%s\"", |