diff options
author | Max Kellermann <max@duempel.org> | 2008-08-29 09:36:40 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-01 18:35:19 -0700 |
commit | 69af10a006bf9e67f4689642e06bae24f67e873d (patch) | |
tree | 128e1d1951a2bb61661a6d6db7226f6502fdbd2c /src | |
parent | 4ad71d6f79dfd8700441a5b3334e10ae5ab9f157 (diff) | |
download | mpd-69af10a006bf9e67f4689642e06bae24f67e873d.tar.gz mpd-69af10a006bf9e67f4689642e06bae24f67e873d.tar.xz mpd-69af10a006bf9e67f4689642e06bae24f67e873d.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 'src')
-rw-r--r-- | src/client.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/client.c b/src/client.c index bce0acd5e..6a43b9586 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); } } |