diff options
author | Max Kellermann <max@duempel.org> | 2008-10-15 18:21:57 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-15 18:21:57 +0200 |
commit | cf7ed8c5df3ca2a4a10c389097732d9e55234ae4 (patch) | |
tree | f56c58fa6277dd2132b55a4addda61edced46a17 /src | |
parent | 6eb62e476195db373c3c1ac05de4fa2adc6ff661 (diff) | |
download | mpd-cf7ed8c5df3ca2a4a10c389097732d9e55234ae4.tar.gz mpd-cf7ed8c5df3ca2a4a10c389097732d9e55234ae4.tar.xz mpd-cf7ed8c5df3ca2a4a10c389097732d9e55234ae4.zip |
idle: client command "noidle" aborts idle
Diffstat (limited to 'src')
-rw-r--r-- | src/client.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/client.c b/src/client.c index 48189992c..5b3b161b5 100644 --- a/src/client.c +++ b/src/client.c @@ -345,6 +345,27 @@ static int client_process_line(struct client *client, char *line) { int ret = 1; + if (strcmp(line, "noidle") == 0) { + if (client->idle_waiting) { + /* send empty idle response and leave idle mode */ + client->idle_waiting = false; + command_success(client); + client_write_output(client); + } + + /* do nothing if the client wasn't idling: the client + has already received the full idle response from + client_idle_notify(), which he can now evaluate */ + + return 0; + } else if (client->idle_waiting) { + /* during idle mode, clients must not send anything + except "noidle" */ + ERROR("client %i: command \"%s\" during idle\n", + client->num, line); + return COMMAND_RETURN_CLOSE; + } + if (client->cmd_list_OK >= 0) { if (strcmp(line, CLIENT_LIST_MODE_END) == 0) { DEBUG("client %i: process command " @@ -418,9 +439,6 @@ static int client_input_received(struct client *client, int bytesRead) char *newline, *next; int ret; - /* any input from the client makes it leave "idle" mode */ - client->idle_waiting = false; - client->bufferLength += bytesRead; /* process all lines */ |