]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afs: Fix error handling of the select command.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 11 Jun 2016 18:44:01 +0000 (20:44 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 26 Aug 2016 20:37:56 +0000 (22:37 +0200)
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

diff --git a/afs.c b/afs.c
index 016329841fe87255cdc68c1191e8661124c1c326..0accc45108f7c6ba0c2a3a89595d957d8a566920 100644 (file)
--- 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",