]> git.pond.sub.org Git - empserver/commitdiff
Clean up how recvclient() deals with command abortion
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 11 Mar 2012 11:32:17 +0000 (12:32 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 26 Apr 2012 17:43:42 +0000 (19:43 +0200)
We must not block in io_input() after command abortion unblocked
io_output().  Instead of checking player->aborted, compute the
deadline according to player->may_sleep, like we do for io_output().

src/lib/player/recvclient.c

index 97cc861771329e5bb51e656eff414b85ea0f2d35..7dacb4508c88a108372590ce980db3f19330d4af 100644 (file)
@@ -87,13 +87,14 @@ recvclient(char *cmd, int size)
            ;
 
        /*
-        * If io_output() blocked and got unblocked by command
-        * abortion, we must return without blocking in io_input().
+        * Try to receive some input.  Need to check player->may_sleep
+        * again; command abortion during io_output() might have
+        * changed it.
         */
-       if (player->aborted)
-           break;
-
-       res = io_input(player->iop, player->curup + minutes(max_idle));
+       deadline = player->curup + minutes(max_idle);
+       if (player->may_sleep < PLAYER_SLEEP_ON_INPUT)
+           deadline = 0;
+       res = io_input(player->iop, deadline);
        if (res > 0)
            ;
        else if (res < 0)