]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Improve handling of oobinline sockets; Plink in telnet mode now
authorSimon Tatham <anakin@pobox.com>
Fri, 1 Nov 2002 13:36:48 +0000 (13:36 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 1 Nov 2002 13:36:48 +0000 (13:36 +0000)
doesn't hang when you hit ^C, which is nice. I think a better
solution would involve nonblocking sockets; as it stands it's a
little dependent on what may be quirks of the Linux socket layer.

[originally from svn r2175]

unix/uxnet.c
unix/uxplink.c

index 44b09c1d998a74136a03efe135e14624ba98fc66..2c9c7f17efe22964e431b0a5831c4bd0b0e973ec 100644 (file)
@@ -810,10 +810,12 @@ int select_result(int fd, int event)
 
        /*
         * If we reach here, this is an oobinline socket, which
-        * means we should set s->oobpending and then fall through
-        * to the read case.
+        * means we should set s->oobpending and then deal with it
+        * when we get called for the readability event (which
+        * should also occur).
         */
        s->oobpending = TRUE;
+        break;
       case 1:                         /* readable; also acceptance */
        if (s->listener) {
            /*
@@ -864,7 +866,7 @@ int select_result(int fd, int event)
        } else
            atmark = 1;
 
-       ret = recv(s->s, buf, sizeof(buf), 0);
+       ret = recv(s->s, buf, s->oobpending ? 1 : sizeof(buf), 0);
        noise_ultralight(ret);
        if (ret < 0) {
            if (errno == EWOULDBLOCK) {
index 453a9f41d998b060ec8be1b7baf5c29c0f8456e2..dab694752b965456811d8cd625e7cdc4b560f090 100644 (file)
@@ -532,12 +532,17 @@ int main(int argc, char **argv)
 
        for (i = 0; i < skcount; i++) {
            socket = sklist[i];
+            /*
+             * We must process exceptional notifications before
+             * ordinary readability ones, or we may go straight
+             * past the urgent marker.
+             */
+           if (FD_ISSET(socket, &xset))
+               select_result(socket, 4);
            if (FD_ISSET(socket, &rset))
                select_result(socket, 1);
            if (FD_ISSET(socket, &wset))
                select_result(socket, 2);
-           if (FD_ISSET(socket, &xset))
-               select_result(socket, 4);
        }
 
        if (FD_ISSET(0, &rset)) {