]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mood: Clear the score table on attribute changes.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 20 Jun 2015 18:26:33 +0000 (20:26 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 25 Jul 2015 11:57:36 +0000 (13:57 +0200)
Although the comment in mood.c correctly states that the score table
must be cleared and reloaded if an attribute is added, removed or
renamed, the mood event handler misses to clear the score table.
Therefore, after reload_current_mood() has reloaded the mood object,
insertion of admissible files fails with

afs_event: table moods, event 0: key already exists in rbtree

This results in an unmodified set of admissible files.

The only other caller of reload_current_mood() clears the score table
right before the function call, so the easiest fix is to move the
call to clear_score_table() into reload_current_mood().

mood.c

diff --git a/mood.c b/mood.c
index e5e8495369f1e7ffffe36bd463ec5aadf6163e39..8e6a7665f15e32bc5774c5539358ccaf0bcbc880 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -896,6 +896,9 @@ static int reload_current_mood(void)
        int ret;
        char *mood_name = NULL;
 
        int ret;
        char *mood_name = NULL;
 
+       ret = clear_score_table();
+       if (ret < 0)
+               return ret;
        if (!current_mood)
                return 1;
        PARA_NOTICE_LOG("reloading %s\n", current_mood->name?
        if (!current_mood)
                return 1;
        PARA_NOTICE_LOG("reloading %s\n", current_mood->name?
@@ -924,8 +927,6 @@ static int reload_current_mood(void)
 int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb,
                void *data)
 {
 int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb,
                void *data)
 {
-       int ret;
-
        if (!current_mood)
                return 0;
        switch (event) {
        if (!current_mood)
                return 0;
        switch (event) {
@@ -938,10 +939,6 @@ int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb
        case BLOB_ADD:
                if (data == moods_table || data == playlists_table)
                        return 1; /* no reload necessary for these */
        case BLOB_ADD:
                if (data == moods_table || data == playlists_table)
                        return 1; /* no reload necessary for these */
-               ret = clear_score_table();
-               if (ret < 0)
-                       PARA_CRIT_LOG("clear score table returned %s\n",
-                               para_strerror(-ret));
                return reload_current_mood();
        /* these also require reload of the score table */
        case ATTRIBUTE_ADD:
                return reload_current_mood();
        /* these also require reload of the score table */
        case ATTRIBUTE_ADD: