aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-22 02:04:23 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-22 02:07:22 -0700
commitada24f9a921ff95d874195acf253b5a9dd12213d (patch)
tree25829d050689696f1c94500062b6c53ea2437d91 /src/command.c
parente3cd520c6441f91655e799e60fe49c4bb7de13bc (diff)
downloadmpd-ada24f9a921ff95d874195acf253b5a9dd12213d.tar.gz
mpd-ada24f9a921ff95d874195acf253b5a9dd12213d.tar.xz
mpd-ada24f9a921ff95d874195acf253b5a9dd12213d.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.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/command.c b/src/command.c
index ebca41bde..f5996c576 100644
--- a/src/command.c
+++ b/src/command.c
@@ -805,13 +805,10 @@ static int listHandleUpdate(int fd,
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
@@ -820,12 +817,8 @@ static int listHandleUpdate(int fd,
if (next)
nextCmd = getCommandEntryFromString(next->data, permission);
- if (cmd != nextCmd) {
- int ret = updateInit(fd, pathList);
- freeList(pathList);
- pathList = NULL;
- return ret;
- }
+ if (cmd != nextCmd)
+ return updateInit(fd, pathList);
return 0;
}
@@ -834,12 +827,9 @@ static int handleUpdate(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[])
{
if (argc == 2) {
- int ret;
List *pathList = makeList(NULL, 1);
insertInList(pathList, argv[1], NULL);
- ret = updateInit(fd, pathList);
- freeList(pathList);
- return ret;
+ return updateInit(fd, pathList);
}
return updateInit(fd, NULL);
}