aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-10-04 02:44:21 -0700
committerEric Wong <normalperson@yhbt.net>2008-10-04 03:21:03 -0700
commite46bbc95eae9bc75e6d809cdf157637b682765c2 (patch)
tree7e8801b4c1cde35d7e3b8a5ac771c2b6c247e229 /src
parentcd1e02c8a88dd3e55cbde3056906dfbd3207f30e (diff)
downloadmpd-e46bbc95eae9bc75e6d809cdf157637b682765c2.tar.gz
mpd-e46bbc95eae9bc75e6d809cdf157637b682765c2.tar.xz
mpd-e46bbc95eae9bc75e6d809cdf157637b682765c2.zip
song: better handling of existing songs when rereading DB
Don't reallocate existing tags if they haven't changed. This isn't used as often anymore, but we still take HUP signals to reread the DB if other processes changed it.
Diffstat (limited to 'src')
-rw-r--r--src/song.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/song.c b/src/song.c
index dc100899a..4f7b2f8bb 100644
--- a/src/song.c
+++ b/src/song.c
@@ -123,11 +123,20 @@ static void insertSongIntoList(struct songvec *sv, Song *newsong)
tag_end_add(newsong->tag);
} else { /* prevent dupes, just update the existing song info */
if (existing->mtime != newsong->mtime) {
- tag_free(existing->tag);
- if (newsong->tag)
- tag_end_add(newsong->tag);
- existing->tag = newsong->tag;
existing->mtime = newsong->mtime;
+ if (tag_equal(existing->tag, newsong->tag)) {
+ if (newsong->tag)
+ tag_free(newsong->tag);
+ } else {
+ struct mpd_tag *old_tag = existing->tag;
+
+ if (newsong->tag)
+ tag_end_add(newsong->tag);
+ existing->tag = newsong->tag;
+ if (old_tag)
+ tag_free(old_tag);
+ }
+ /* prevent tag_free in freeJustSong */
newsong->tag = NULL;
}
freeJustSong(newsong);