From 52a56f14cb581febf36b92506f4d0db0ba7cf42c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 28 Sep 2008 03:38:13 -0700 Subject: directory: replace DirectoryList with dirvec Small memory reduction compared to songvec since most users have much fewer dirs than songs, but still nice to have. --- src/directory.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/directory.h') diff --git a/src/directory.h b/src/directory.h index e2ff3832a..b93e6bddb 100644 --- a/src/directory.h +++ b/src/directory.h @@ -23,11 +23,14 @@ #include "songvec.h" #include "list.h" -typedef List DirectoryList; +struct dirvec { + struct _Directory **base; + size_t nr; +}; typedef struct _Directory { char *path; - DirectoryList *subDirectories; + struct dirvec children; struct songvec songs; struct _Directory *parent; ino_t inode; -- cgit v1.2.3 From 3ab37f7580f97987f8c4c9787c07715b8279db57 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 28 Sep 2008 03:46:05 -0700 Subject: directory.h: remove directory_sigChldHandler decl We no longer fork for directory updates, so we no longer have children to reap. --- src/directory.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/directory.h') diff --git a/src/directory.h b/src/directory.h index b93e6bddb..fedeb9fa2 100644 --- a/src/directory.h +++ b/src/directory.h @@ -42,8 +42,6 @@ void reap_update_task(void); int isUpdatingDB(void); -void directory_sigChldHandler(int pid, int status); - int updateInit(int fd, List * pathList); void initMp3Directory(void); -- cgit v1.2.3 From 60f52cfb620cf3d273122036f5e23783d267dc61 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 28 Sep 2008 19:43:28 -0700 Subject: directory: remove "Mp3" references MPD has supported more audio formats than just MP3 for over five years... --- src/directory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/directory.h') diff --git a/src/directory.h b/src/directory.h index fedeb9fa2..5c4c76a25 100644 --- a/src/directory.h +++ b/src/directory.h @@ -44,9 +44,9 @@ int isUpdatingDB(void); int updateInit(int fd, List * pathList); -void initMp3Directory(void); +void directory_init(void); -void closeMp3Directory(void); +void directory_finish(void); int isRootDirectory(const char *name); -- cgit v1.2.3 From 887f97b868886a66d7bb2fcd0e1fd6810297299d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 28 Sep 2008 20:29:40 -0700 Subject: clean up updateInit calling and error handling Move error reporting to command.c so directory.c does not deal with client error handling any more. --- src/directory.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/directory.h') diff --git a/src/directory.h b/src/directory.h index 5c4c76a25..9161efc38 100644 --- a/src/directory.h +++ b/src/directory.h @@ -42,7 +42,8 @@ void reap_update_task(void); int isUpdatingDB(void); -int updateInit(int fd, List * pathList); +/* returns the non-negative update job ID on success, -1 on error */ +int updateInit(List * pathList); void directory_init(void); -- cgit v1.2.3 From 659a543da853bcb28c22df300a93bd22dc9ae877 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 29 Sep 2008 02:48:09 -0700 Subject: update: move path sanitation up the stack to avoid extra copies Remove yet another use of our old malloc-happy linked list implementation and replace it with a simple array of strings. This also implements more eager error handling of invalid paths (still centralized in updateInit) so we can filter out bad paths before we spawn a thread. This also does its part to fix the "update" command inside list mode which lost its static variable in ada24f9a921ff95d874195acf253b5a9dd12213d (although it was broken and requires the fix in 769939b62f7557f8e7c483223d68a8b39af43e37, too). --- src/directory.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/directory.h') diff --git a/src/directory.h b/src/directory.h index 9161efc38..eb1b35aa7 100644 --- a/src/directory.h +++ b/src/directory.h @@ -21,7 +21,6 @@ #include "song.h" #include "songvec.h" -#include "list.h" struct dirvec { struct _Directory **base; @@ -42,8 +41,13 @@ void reap_update_task(void); int isUpdatingDB(void); -/* returns the non-negative update job ID on success, -1 on error */ -int updateInit(List * pathList); +/* + * returns the non-negative update job ID on success, + * -1 if busy, -2 if invalid argument + * @argv itself is safe to free once updateInit returns, but the + * string values contained by @argv MUST NOT be freed manually + */ +int updateInit(int argc, char *argv[]); void directory_init(void); -- cgit v1.2.3