From ada24f9a921ff95d874195acf253b5a9dd12213d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 22 Sep 2008 02:04:23 -0700 Subject: 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. --- src/command.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/command.c') 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); } -- cgit v1.2.3