aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-01-10 21:40:15 +0100
committerMax Kellermann <max@duempel.org>2011-01-10 21:40:15 +0100
commit1025f0be915b93887ada998aa793ddf0becc2ccd (patch)
treea2bcc5358c3c2eff75eb1450948726fe30ff168c /src
parent77d3b5e8f18e128f3bb17cad8fb169ea659d7f13 (diff)
downloadmpd-1025f0be915b93887ada998aa793ddf0becc2ccd.tar.gz
mpd-1025f0be915b93887ada998aa793ddf0becc2ccd.tar.xz
mpd-1025f0be915b93887ada998aa793ddf0becc2ccd.zip
update_remove: use plain GCond instead of notify
GMutex/GCond guarantee that the access to removed_song is protected.
Diffstat (limited to 'src')
-rw-r--r--src/update_remove.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/update_remove.c b/src/update_remove.c
index 8bec5fd6d..68cbb22b7 100644
--- a/src/update_remove.c
+++ b/src/update_remove.c
@@ -19,7 +19,6 @@
#include "config.h" /* must be first for large file support */
#include "update_internal.h"
-#include "notify.h"
#include "event_pipe.h"
#include "song.h"
#include "playlist.h"
@@ -36,7 +35,8 @@
static const struct song *removed_song;
-static struct notify remove_notify;
+static GMutex *remove_mutex;
+static GCond *remove_cond;
/**
* Safely remove a song from the database. This must be done in the
@@ -60,15 +60,19 @@ song_remove_event(void)
#endif
playlist_delete_song(&g_playlist, global_player_control, removed_song);
- removed_song = NULL;
- notify_signal(&remove_notify);
+ /* clear "removed_song" and send signal to update thread */
+ g_mutex_lock(remove_mutex);
+ removed_song = NULL;
+ g_cond_signal(remove_cond);
+ g_mutex_unlock(remove_mutex);
}
void
update_remove_global_init(void)
{
- notify_init(&remove_notify);
+ remove_mutex = g_mutex_new();
+ remove_cond = g_cond_new();
event_pipe_register(PIPE_EVENT_DELETE, song_remove_event);
}
@@ -76,7 +80,8 @@ update_remove_global_init(void)
void
update_remove_global_finish(void)
{
- notify_deinit(&remove_notify);
+ g_mutex_free(remove_mutex);
+ g_cond_free(remove_cond);
}
void
@@ -88,8 +93,10 @@ update_remove_song(const struct song *song)
event_pipe_emit(PIPE_EVENT_DELETE);
- do {
- notify_wait(&remove_notify);
- } while (removed_song != NULL);
+ g_mutex_lock(remove_mutex);
+
+ while (removed_song != NULL)
+ g_cond_wait(remove_cond, remove_mutex);
+ g_mutex_unlock(remove_mutex);
}