There was some confusion about how to determine whether the dummy mode
is currently active. At some places we tested if current_mood is NULL,
at others if current_mood->name is NULL. In fact neither check works:
* if a playlist is open, current_mood is NULL (but the dummy
mood is not loaded),
* loading the dummy mood currently sets current_mood->name to
"(dummy)".
This patch makes the latter variant the official one and fixes up
the code accordingly.
This also fixes the critical log message
Jan 27 18:57:29 (5) (13487) afs_event: table moods, event 9: key not found in rbtree
which occured if the dummy mood was active while an event caused the
mood to be reloaded.
struct list_head score_list;
};
struct list_head score_list;
};
+/*
+ * If current_mood is NULL then no mood is currently open. If
+ * current_mood->name is NULL, the dummy mood is currently open
+ */
static struct mood *current_mood;
/**
static struct mood *current_mood;
/**
static struct mood *alloc_new_mood(const char *name)
{
struct mood *m = para_calloc(sizeof(struct mood));
static struct mood *alloc_new_mood(const char *name)
{
struct mood *m = para_calloc(sizeof(struct mood));
- m->name = para_strdup(name);
+ if (name)
+ m->name = para_strdup(name);
INIT_LIST_HEAD(&m->accept_list);
INIT_LIST_HEAD(&m->deny_list);
INIT_LIST_HEAD(&m->score_list);
INIT_LIST_HEAD(&m->accept_list);
INIT_LIST_HEAD(&m->deny_list);
INIT_LIST_HEAD(&m->score_list);
return ret;
close_current_mood();
current_mood = m;
return ret;
close_current_mood();
current_mood = m;
+ } else { /* load dummy mood */
- current_mood = alloc_new_mood("dummy");
+ current_mood = alloc_new_mood(NULL);
}
aa.m = current_mood;
PARA_NOTICE_LOG("computing statistics of admissible files\n");
}
aa.m = current_mood;
PARA_NOTICE_LOG("computing statistics of admissible files\n");
- PARA_NOTICE_LOG("loaded mood %s\n", current_mood->name);
+ PARA_NOTICE_LOG("loaded mood %s\n", mood_name? mood_name : "(dummy)");
ret = statistics.num;
out:
free(aa.array);
ret = statistics.num;
out:
free(aa.array);