diff options
author | Max Kellermann <max@duempel.org> | 2012-01-31 22:12:14 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-02-02 18:06:33 +0100 |
commit | ef5cf40fa6d3e2f50ad916be8e5bd99affe7d2e3 (patch) | |
tree | bffd4ea35f30f96e8dc8d1ac74184bd4dab5d5d6 /src/command.c | |
parent | 837bd79b20d4b9b8525a42999a9d1911f8980aa4 (diff) | |
download | mpd-ef5cf40fa6d3e2f50ad916be8e5bd99affe7d2e3.tar.gz mpd-ef5cf40fa6d3e2f50ad916be8e5bd99affe7d2e3.tar.xz mpd-ef5cf40fa6d3e2f50ad916be8e5bd99affe7d2e3.zip |
directory: require the caller to lock the db_mutex
Reduce the number of lock/unlock cycles, and make database handling
safer.
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c index e6bf36ac9..9810049ea 100644 --- a/src/command.c +++ b/src/command.c @@ -45,6 +45,7 @@ #include "db_error.h" #include "db_print.h" #include "db_selection.h" +#include "db_lock.h" #include "tag.h" #include "client.h" #include "client_idle.h" @@ -1892,8 +1893,10 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) .name = argv[4], }; + db_lock(); directory = db_get_directory(argv[3]); if (directory == NULL) { + db_unlock(); command_error(client, ACK_ERROR_NO_EXIST, "no such directory"); return COMMAND_RETURN_ERROR; @@ -1901,6 +1904,7 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) success = sticker_song_find(directory, data.name, sticker_song_find_print_cb, &data); + db_unlock(); if (!success) { command_error(client, ACK_ERROR_SYSTEM, "failed to set search sticker database"); |