Don't lose output when client shuts down input transmission

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.
This commit is contained in:
Markus Armbruster 2012-01-28 16:48:08 +01:00
parent bdc1c40f0a
commit 16879f3db2

View 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");
pr_id(player, C_EXIT, "so long...\n"); while (io_output(player->iop, 1) > 0) ;
while (io_output(player->iop, 1) > 0) ;
}
player_delete(player); player_delete(player);
empth_exit(); empth_exit();
/*NOTREACHED*/ /*NOTREACHED*/
@ -384,7 +382,6 @@ kill_cmd(void)
static int static int
quit_cmd(void) quit_cmd(void)
{ {
pr_id(player, C_EXIT, "so long\n");
io_shutdown(player->iop, IO_READ); io_shutdown(player->iop, IO_READ);
return RET_OK; return RET_OK;
} }