Completely remove the 'frozen_readable' mechanism from uxnet.c. It
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 21 Jul 2013 07:40:36 +0000 (07:40 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 21 Jul 2013 07:40:36 +0000 (07:40 +0000)
parallels a similar mechanism in winnet.c and came over by copy and
paste, but is pointless in the Unix networking API.

On Windows, if you're using a mechanism such as WSAAsyncSelect which
delivers readability notifications as messages rather than return
values from a system call, you only get notified that a socket is
readable once - it remembers that it's told you, and doesn't tell you
again until after you've done a read. So in the case where we
intentionally stop reading from a socket because our local buffer is
full, and later want to start reading again, we do a read from the
socket with MSG_PEEK set, and that clears Windows's flag and tells it
to start sending us readability notifications again.

On Unix, select() and friends didn't do anything so strange in the
first place, so the whole mechanism is unnecessary.

git-svn-id: svn://svn.tartarus.org/sgt/putty@9951 cda61777-01e9-0310-a592-d414129be87e

unix/uxnet.c

index 02894bd..5190ef8 100644 (file)
@@ -80,8 +80,6 @@ struct Socket_tag {
     int connected;                    /* irrelevant for listening sockets */
     int writable;
     int frozen; /* this causes readability notifications to be ignored */
-    int frozen_readable; /* this means we missed at least one readability
-                         * notification while we were frozen */
     int localhost_only;                       /* for listening sockets */
     char oobdata[1];
     int sending_oob;
@@ -507,7 +505,6 @@ Socket sk_register(OSSocket sockfd, Plug plug)
     ret->writable = 1;                /* to start with */
     ret->sending_oob = 0;
     ret->frozen = 1;
-    ret->frozen_readable = 0;
     ret->localhost_only = 0;          /* unused, but best init anyway */
     ret->pending_error = 0;
     ret->oobpending = FALSE;
@@ -743,7 +740,6 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
     ret->writable = 0;                /* to start with */
     ret->sending_oob = 0;
     ret->frozen = 0;
-    ret->frozen_readable = 0;
     ret->localhost_only = 0;          /* unused, but best init anyway */
     ret->pending_error = 0;
     ret->parent = ret->child = NULL;
@@ -797,7 +793,6 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i
     ret->writable = 0;                /* to start with */
     ret->sending_oob = 0;
     ret->frozen = 0;
-    ret->frozen_readable = 0;
     ret->localhost_only = local_host_only;
     ret->pending_error = 0;
     ret->parent = ret->child = NULL;
@@ -1277,10 +1272,8 @@ static int net_select_result(int fd, int event)
         */
 
        /* In the case the socket is still frozen, we don't even bother */
-       if (s->frozen) {
-           s->frozen_readable = 1;
+       if (s->frozen)
            break;
-       }
 
        /*
         * We have received data on the socket. For an oobinline
@@ -1433,11 +1426,6 @@ static void sk_tcp_set_frozen(Socket sock, int is_frozen)
     if (s->frozen == is_frozen)
        return;
     s->frozen = is_frozen;
-    if (!is_frozen && s->frozen_readable) {
-       char c;
-       recv(s->s, &c, 1, MSG_PEEK);
-    }
-    s->frozen_readable = 0;
     uxsel_tell(s);
 }