]> git.pond.sub.org Git - empserver/commitdiff
client: Fix obscure misdetection of input EOF
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 2 Jan 2016 09:11:28 +0000 (10:11 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 09:22:29 +0000 (11:22 +0200)
recv_input(input_fd, &inbuf) returns zero when @inbuf is full or
@input_fd is at EOF.  We avoid the former by putting @input_fd in
@rdfd only when @inbuf has space, so we can detect EOF easily.  But we
missed the case where adding a cookie fills up @inbuf.  We
misinterpret "can't read into full buffer" as "EOF on input" then.

Fix by checking for space again.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/client/play.c

index bc7f629b785d19f496ad2529d08fca3d74fc988d..89c2f66a6e602b8a8a1b37b27c949c1c9554bbbd 100644 (file)
@@ -27,7 +27,7 @@
  *  play.c: Playing the game
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2007-2015
+ *     Markus Armbruster, 2007-2016
  *     Ron Koenderink, 2007-2009
  */
 
@@ -523,7 +523,7 @@ play(int sock)
            continue;
 
        /* read player input */
-       if (FD_ISSET(input_fd, &rdfd)) {
+       if (FD_ISSET(input_fd, &rdfd) && ring_space(&inbuf)) {
            n = recv_input(input_fd, &inbuf);
            if (n <= 0) {
                if (input_fd) {