]> git.pond.sub.org Git - empserver/commitdiff
Fix how play_cmd() ensures connection close
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 22 Feb 2012 13:30:58 +0000 (14:30 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Feb 2012 10:32:02 +0000 (11:32 +0100)
play_cmd() needs to return in a state that makes player_login() break
the login command loop.

play_cmd() assumes player_main() always returns in such a state:
connection's EOF indicator set.  Unfortunately, the assumption is
wrong.  Fortunately, play_cmd() checks it, oopses and recovers.

player_main() can return with neiter error nor EOF indicator set,
e.g. when the game is down.

player_main() can return with just the error indicator set.  For
instance, when the client dies, io_input() detects ECONNRESET, sets
the error indicator and fails.

Broken in commit 8549efbc.  Fix by setting the EOF indicator silently
(without oopsing) when necessary.

src/lib/player/login.c

index 1f5400c9e4c9720439971f58856dfae58a34e2a9..fd56f531dfa6e34c5a2f11a622779545b108772b 100644 (file)
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Dave Pare, 1994
  *     Steve McClure, 2000
- *     Markus Armbruster, 2004-2011
+ *     Markus Armbruster, 2004-2012
  *     Ron Koenderink, 2005-2009
  */
 
@@ -357,7 +357,7 @@ play_cmd(void)
     player->state = PS_PLAYING;
     player_main(player);
     logerror("%s logged out, country #%d", praddr(player), player->cnum);
-    if (CANT_HAPPEN(!io_eof(player->iop)))
+    if (!io_eof(player->iop) && !io_error(player->iop))
        io_set_eof(player->iop);
     return RET_OK;
 }