Flush all output before reading a login command, not just some

Before, a client could theoretically make the output queue grow
without bounds.
This commit is contained in:
Markus Armbruster 2012-03-11 11:43:38 +01:00
parent 5ce099f671
commit d381351c65

View file

@ -87,7 +87,11 @@ player_login(void *ud)
pr_id(player, C_INIT, "Empire server ready\n");
for (;;) {
io_output(player->iop, (time_t)-1);
if (io_outputwaiting(player->iop)) {
if (io_output(player->iop, (time_t)-1) <= 0)
break;
continue;
}
if (io_gets(player->iop, buf, sizeof(buf)) < 0) {
res = io_input(player->iop, player->curup + minutes(max_idle));
if (res <= 0) {