aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-23 22:37:18 +0200
committerMax Kellermann <max@duempel.org>2008-09-23 22:37:18 +0200
commit3f0ae13c4b409bcf39d926f5e73d5eb0feff6eb3 (patch)
treeb01aacd0c3c3ab7f7018830d630ada1d9d3838ae /src/command.c
parent0f0ac43b8fa4dfecad5548cde42152dba8d9a652 (diff)
downloadmpd-3f0ae13c4b409bcf39d926f5e73d5eb0feff6eb3.tar.gz
mpd-3f0ae13c4b409bcf39d926f5e73d5eb0feff6eb3.tar.xz
mpd-3f0ae13c4b409bcf39d926f5e73d5eb0feff6eb3.zip
directory: update do its work inside a thread
A lot of the preparation was needed (and done in previous months) in making update thread-safe, but here it is. This was the first thing I made work inside a thread when I started mpd-uclinux many years ago, and also the last thing I've done in mainline mpd to work inside a thread, go figure.
Diffstat (limited to '')
-rw-r--r--src/command.c47
1 files changed, 6 insertions, 41 deletions
diff --git a/src/command.c b/src/command.c
index 2e45d6d25..0cd115cc5 100644
--- a/src/command.c
+++ b/src/command.c
@@ -819,13 +819,10 @@ static int listHandleUpdate(struct client *client,
char *argv[],
struct strnode *cmdnode, CommandEntry * cmd)
{
- static List *pathList;
+ List *pathList = makeList(NULL, 1);
CommandEntry *nextCmd = NULL;
struct strnode *next = cmdnode->next;
- if (!pathList)
- pathList = makeList(NULL, 1);
-
if (argc == 2)
insertInList(pathList, argv[1], NULL);
else
@@ -837,25 +834,9 @@ static int listHandleUpdate(struct client *client,
if (cmd != nextCmd) {
int ret = updateInit(pathList);
- freeList(pathList);
- pathList = NULL;
-
- switch (ret) {
- case 0:
+ if (ret == -1)
command_error(client, ACK_ERROR_UPDATE_ALREADY,
"already updating");
- break;
-
- case -1:
- command_error(client, ACK_ERROR_SYSTEM,
- "problems trying to update");
- break;
-
- default:
- client_printf(client, "updating_db: %i\n", ret);
- ret = 0;
- break;
- }
return ret;
}
@@ -872,26 +853,10 @@ static int handleUpdate(struct client *client,
List *pathList = makeList(NULL, 1);
insertInList(pathList, argv[1], NULL);
ret = updateInit(pathList);
- freeList(pathList);
- } else
- ret = updateInit(NULL);
-
- switch (ret) {
- case 0:
- command_error(client, ACK_ERROR_UPDATE_ALREADY,
- "already updating");
- ret = -1;
- break;
-
- case -1:
- command_error(client, ACK_ERROR_SYSTEM,
- "problems trying to update");
- break;
-
- default:
- client_printf(client, "updating_db: %i\n", ret);
- ret = 0;
- break;
+ if (ret == -1)
+ command_error(client, ACK_ERROR_UPDATE_ALREADY,
+ "already updating");
+ return ret;
}
return ret;