aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:36:38 +0200
committerMax Kellermann <max@duempel.org>2008-08-29 09:36:38 +0200
commit76ecc3024371e6272493e77a311e0cb079a49216 (patch)
tree4f1deea27a20878c3810da84a259ffb243d27852
parent12bcba8b89ad503cbdfb8261c5c26b9f87860345 (diff)
downloadmpd-76ecc3024371e6272493e77a311e0cb079a49216.tar.gz
mpd-76ecc3024371e6272493e77a311e0cb079a49216.tar.xz
mpd-76ecc3024371e6272493e77a311e0cb079a49216.zip
client: added global "expired" flag
Patch bdeb8e14 ("client: moved "expired" accesses into inline function") was created under the wrong assumption that processListOfCommands() could modify the expired flag, which is not the case. Although "expired" is a non-const pointer, processListOfCommands() just reads it, using it as the break condition in a "while" loop. I will address this issue with a better overall solution, but for now provide a pointer to a global "expired" flag.
-rw-r--r--src/client.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/client.c b/src/client.c
index 953037e1b..b4aea2085 100644
--- a/src/client.c
+++ b/src/client.c
@@ -134,12 +134,16 @@ static inline int client_is_expired(const struct client *client)
return client->fd < 0;
}
+static int global_expired;
+
static inline void client_set_expired(struct client *client)
{
if (client->fd >= 0) {
xclose(client->fd);
client->fd = -1;
}
+
+ global_expired = 1;
}
static void client_init(struct client *client, int fd)
@@ -327,21 +331,18 @@ static int client_process_line(struct client *client)
if (client->cmd_list_OK >= 0) {
if (strcmp(line, CLIENT_LIST_MODE_END) == 0) {
- int expired;
-
DEBUG("client %i: process command "
"list\n", client->num);
+
+ global_expired = 0;
ret = processListOfCommands(client->fd,
&(client->permission),
- &(expired),
+ &global_expired,
client->cmd_list_OK,
client->cmd_list);
DEBUG("client %i: process command "
"list returned %i\n", client->num, ret);
- if (expired)
- client_set_expired(client);
-
if (ret == 0)
commandSuccess(client->fd);
else if (ret == COMMAND_RETURN_CLOSE