aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-11 20:46:55 +0100
committerMax Kellermann <max@duempel.org>2008-11-11 20:46:55 +0100
commit1bfa6a94e2259201068d7a947507eb5e6e93c0c3 (patch)
tree0acf5a246f1889d1643a885dbb11395efe56d9b0 /src
parentacf0d141be9bae98311be9479fc46e77f6f87961 (diff)
downloadmpd-1bfa6a94e2259201068d7a947507eb5e6e93c0c3.tar.gz
mpd-1bfa6a94e2259201068d7a947507eb5e6e93c0c3.tar.xz
mpd-1bfa6a94e2259201068d7a947507eb5e6e93c0c3.zip
player: fix race condition during tag update
When a tag is updated, the old tag was freed before the new one was created. Reverse the order to be sure that other threads always see a valid pointer. This still leaves a possible race condition, but it will be addressed later.
Diffstat (limited to 'src')
-rw-r--r--src/player_thread.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/player_thread.c b/src/player_thread.c
index 30f876fe0..ddd87cc06 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -225,11 +225,13 @@ play_chunk(struct song *song, struct music_chunk *chunk,
if (!song_is_file(song)) {
/* always update the tag of remote streams */
+ struct tag *old_tag = song->tag;
- if (song->tag != NULL)
- tag_free(song->tag);
song->tag = tag_dup(chunk->tag);
+ if (old_tag != NULL)
+ tag_free(old_tag);
+
/* notify all clients that the tag of the
current song has changed */
idle_add(IDLE_PLAYER);