From 048c921d16110d350572698c22033d51b091ce1b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 11 Jun 2016 20:44:01 +0200 Subject: [PATCH] afs: Fix error handling of the select command. com_select() returns success even if the mood or playlist could not be activated. This commit changes the function to return the error code from activate_mood_or_playlist() instead. The function had another minor issue: If the current mood is the dummy mood, and we failed to switch to the given mood or playlist, and also failed to switch back to the dummy mood, we try a second time to activate the dummy mood. This should not happen, but let's fix it anyway. --- afs.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/afs.c b/afs.c index 01632984..0accc451 100644 --- a/afs.c +++ b/afs.c @@ -607,14 +607,17 @@ static int com_select_callback(struct afs_callback_arg *aca) if (ret >= 0) goto out; /* ignore subsequent errors (but log them) */ - para_printf(&aca->pbout, "could not activate %s: %s\n" - "switching back to %s\n", - arg, para_strerror(-ret), current_mop? current_mop : "dummy"); - ret = activate_mood_or_playlist(current_mop, &num_admissible); - if (ret >= 0) - goto out; - para_printf(&aca->pbout, "could not activate %s: %s\nswitching to dummy\n", - current_mop, para_strerror(-ret)); + para_printf(&aca->pbout, "could not activate %s\n", arg); + if (current_mop) { + int ret2; + para_printf(&aca->pbout, "switching back to %s\n", current_mop); + ret2 = activate_mood_or_playlist(current_mop, &num_admissible); + if (ret2 >= 0) + goto out; + para_printf(&aca->pbout, "could not reactivate %s: %s\n", + current_mop, para_strerror(-ret2)); + } + para_printf(&aca->pbout, "activating dummy mood\n"); activate_mood_or_playlist(NULL, &num_admissible); out: para_printf(&aca->pbout, "activated %s (%d admissible files)\n", -- 2.39.5