]> git.pond.sub.org Git - empserver/commitdiff
Don't lose output when client shuts down input transmission
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 28 Jan 2012 15:48:08 +0000 (16:48 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 20 Feb 2012 06:44:21 +0000 (07:44 +0100)
player_login() skips sending C_EXIT and flushing server output when
io_eof() is true.  That's the case after a read from the socket
returned zero, which means the client has shut down transmission on
his socket, or closed it.  If it's the former, then dropping output
like that is bad.  Our client never does that, but others might.

Condition was introduced in Empire 2, don't know why.

src/lib/player/login.c

index 99cba66238ee8ef7fe25acf9b4bab9a299ad104e..d422001204e645f5650614af5b893334a67862db 100644 (file)
@@ -121,10 +121,8 @@ player_login(void *ud)
        }
     }
     player->state = PS_SHUTDOWN;
        }
     }
     player->state = PS_SHUTDOWN;
-    if (!io_eof(player->iop)) {
-       pr_id(player, C_EXIT, "so long...\n");
-       while (io_output(player->iop, 1) > 0) ;
-    }
+    pr_id(player, C_EXIT, "so long...\n");
+    while (io_output(player->iop, 1) > 0) ;
     player_delete(player);
     empth_exit();
     /*NOTREACHED*/
     player_delete(player);
     empth_exit();
     /*NOTREACHED*/
@@ -384,7 +382,6 @@ kill_cmd(void)
 static int
 quit_cmd(void)
 {
 static int
 quit_cmd(void)
 {
-    pr_id(player, C_EXIT, "so long\n");
     io_shutdown(player->iop, IO_READ);
     return RET_OK;
 }
     io_shutdown(player->iop, IO_READ);
     return RET_OK;
 }