aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-09 19:17:44 +0200
committerEric Wong <normalperson@yhbt.net>2008-10-11 19:21:51 -0700
commit1d59716731f3ed8569d60ae84c291bd93eb7d582 (patch)
tree6c8e6e5e43190d98264f7c734102af7bb5e4ec96
parente5c747982adfae06c51b60819ec6a4ef5a34ffe2 (diff)
downloadmpd-1d59716731f3ed8569d60ae84c291bd93eb7d582.tar.gz
mpd-1d59716731f3ed8569d60ae84c291bd93eb7d582.tar.xz
mpd-1d59716731f3ed8569d60ae84c291bd93eb7d582.zip
update: job ID must be positive
The documentation for directory_update_init() was incorrect: a job ID must be positive, not non-negative. If the update queue is full and no job was created, it makes more sense to return 0 instead of -1, because it is more consistent with the return value of isUpdatingDB().
-rw-r--r--src/command.c8
-rw-r--r--src/database.c2
-rw-r--r--src/update.c4
-rw-r--r--src/update.h4
4 files changed, 8 insertions, 10 deletions
diff --git a/src/command.c b/src/command.c
index aafb88418..541a71a50 100644
--- a/src/command.c
+++ b/src/command.c
@@ -788,14 +788,12 @@ static int handlePlaylistMove(int fd, mpd_unused int *permission,
static int print_update_result(int fd, int ret)
{
- if (ret >= 0) {
+ if (ret > 0) {
fdprintf(fd, "updating_db: %i\n", ret);
return 0;
}
- if (ret == -2)
- commandError(fd, ACK_ERROR_ARG, "invalid path");
- else
- commandError(fd, ACK_ERROR_UPDATE_ALREADY, "already updating");
+ assert(!ret);
+ commandError(fd, ACK_ERROR_UPDATE_ALREADY, "already updating");
return -1;
}
diff --git a/src/database.c b/src/database.c
index 3a1667bb6..ea78940f8 100644
--- a/src/database.c
+++ b/src/database.c
@@ -40,7 +40,7 @@ void db_init(void)
{
music_root = directory_new("", NULL);
- if (directory_update_init(NULL) < 0)
+ if (!directory_update_init(NULL))
FATAL("directory update failed\n");
do {
diff --git a/src/update.c b/src/update.c
index f5619a1d4..7dc50b5aa 100644
--- a/src/update.c
+++ b/src/update.c
@@ -418,9 +418,9 @@ int directory_update_init(char *path)
int next_task_id;
if (!path)
- return -1;
+ return 0;
if (update_paths_nr == ARRAY_SIZE(update_paths))
- return -1;
+ return 0;
assert(update_paths_nr < ARRAY_SIZE(update_paths));
update_paths[update_paths_nr++] = path;
next_task_id = update_task_id + update_paths_nr;
diff --git a/src/update.h b/src/update.h
index 0c0d74416..5c7277e32 100644
--- a/src/update.h
+++ b/src/update.h
@@ -23,8 +23,8 @@
int isUpdatingDB(void);
/*
- * returns the non-negative update job ID on success,
- * returns -1 if busy
+ * returns the positive update job ID on success,
+ * returns 0 if busy
* @path will be freed by this function and should not be reused
*/
int directory_update_init(char *path);