aboutsummaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:36:40 +0200
committerMax Kellermann <max@duempel.org>2008-08-29 09:36:40 +0200
commite743d71b89c0799d7e7401b1b777236641afb236 (patch)
tree1cecdb613067178710970ae20b3fbcd35ee4eda5 /src/client.c
parent76ecc3024371e6272493e77a311e0cb079a49216 (diff)
downloadmpd-e743d71b89c0799d7e7401b1b777236641afb236.tar.gz
mpd-e743d71b89c0799d7e7401b1b777236641afb236.tar.xz
mpd-e743d71b89c0799d7e7401b1b777236641afb236.zip
client: check "expired" after command execution
The old code tried to write a response to the client, without even checking if it was already closed. Now that we have added more assertions, these may fail... perform the "expired" check earlier.
Diffstat (limited to '')
-rw-r--r--src/client.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/client.c b/src/client.c
index b4aea2085..c0cca399e 100644
--- a/src/client.c
+++ b/src/client.c
@@ -343,11 +343,14 @@ static int client_process_line(struct client *client)
DEBUG("client %i: process command "
"list returned %i\n", client->num, ret);
+ if (ret == COMMAND_RETURN_CLOSE ||
+ client_is_expired(client)) {
+ client_close(client);
+ return COMMAND_RETURN_CLOSE;
+ }
+
if (ret == 0)
commandSuccess(client->fd);
- else if (ret == COMMAND_RETURN_CLOSE
- || client_is_expired(client))
- client_close(client);
client_write_output(client);
free_cmd_list(client->cmd_list);
@@ -385,12 +388,16 @@ static int client_process_line(struct client *client)
&(client->permission), line);
DEBUG("client %i: command returned %i\n",
client->num, ret);
- if (ret == 0)
- commandSuccess(client->fd);
- else if (ret == COMMAND_RETURN_CLOSE
- || client_is_expired(client)) {
+
+ if (ret == COMMAND_RETURN_CLOSE ||
+ client_is_expired(client)) {
client_close(client);
+ return COMMAND_RETURN_CLOSE;
}
+
+ if (ret == 0)
+ commandSuccess(client->fd);
+
client_write_output(client);
}
}