]> git.pond.sub.org Git - empserver/blobdiff - src/lib/player/login.c
Reimplement max_idle without a separate thread
[empserver] / src / lib / player / login.c
index 63d3c3f17ee1a0566a74f215633bbe91a377c045..c2be754d3b31822b8ec0ac1f1babd462964c186c 100644 (file)
@@ -79,16 +79,21 @@ player_login(void *ud)
     char space[128];
     int ac;
     int cmd;
+    int res;
 
     player->proc = empth_self();
 
     pr_id(player, C_INIT, "Empire server ready\n");
 
-    while (!io_eof(player->iop) && !io_error(player->iop)
-          && player->state != PS_SHUTDOWN) {
+    while (player->state != PS_SHUTDOWN) {
        io_output(player->iop, IO_WAIT);
        if (io_gets(player->iop, buf, sizeof(buf)) < 0) {
-           io_input(player->iop, IO_WAIT);
+           res = io_input(player->iop, IO_WAIT);
+           if (res <= 0) {
+               if (res == 0 && !io_eof(player->iop))
+                   pr_id(player, C_DATA, "idle connection terminated\n");
+               break;
+           }
            continue;
        }
        ac = parse(buf, space, player->argp, NULL, NULL, NULL);