NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/47584: rlogin(1): responsiveness could be better



 |>Number:         47584
 |>Category:       bin
 |>Synopsis:       rlogin(1): responsiveness could be better
 |>Description:
 |Other BSD systems offer the -D flag which enables TCP_NODELAY, and that, \
 |when used, improves responsiveness massively in a normal terminal session.
 |>Fix:
 |I'll reply with a patch that adds -D (better than pasting here).

(Also cleans up some weird spacing.)

--steffen

diff -Napru rlogin.orig/rlogin.1 rlogin/rlogin.1
--- rlogin.orig/rlogin.1        2013-02-22 13:37:55.000000000 +0100
+++ rlogin/rlogin.1     2013-02-22 14:33:35.000000000 +0100
@@ -29,7 +29,7 @@
 .\"
 .\"    @(#)rlogin.1    8.2 (Berkeley) 4/29/95
 .\"
-.Dd July 16, 2005
+.Dd Febuary 22, 2013
 .Dt RLOGIN 1
 .Os
 .Sh NAME
@@ -37,20 +37,20 @@
 .Nd remote login
 .Sh SYNOPSIS
 .Nm
-.Op Fl 468Ed
+.Op Fl 468DdE
 .Op Fl e Ar char
 .Op Fl l Ar username
 .Op Fl p Ar port
 .Ar host
 .Nm
-.Op Fl 468Ed
+.Op Fl 468DdE
 .Op Fl e Ar char
 .Op Fl p Ar port
 .Ar username@host
 .Sh DESCRIPTION
 .Nm
 starts a terminal session on a remote host
-.Ar host  .
+.Ar host .
 .Pp
 .Nm
 first attempts to use the standard Berkeley
@@ -69,6 +69,18 @@ option allows an eight-bit input data pa
 parity bits are stripped except when the remote side's stop and start
 characters are other than
 .Sq \&^S/^Q .
+.It Fl D
+Set the
+.Dv TCP_NODELAY
+socket option,
+which can improve interactive responsiveness at the possible downside of
+increased network load.
+.It Fl d
+The
+.Fl d
+option turns on socket debugging (see
+.Xr setsockopt 2 )
+on the TCP sockets used for communication with the remote host.
 .It Fl E
 The
 .Fl E
@@ -76,12 +88,6 @@ option stops any character from being re
 When used with the
 .Fl 8
 option, this provides a completely transparent connection.
-.It Fl d
-The
-.Fl d
-option turns on socket debugging (see
-.Xr setsockopt 2 )
-on the TCP sockets used for communication with the remote host.
 .It Fl e Ar char
 The
 .Fl e
diff -Napru rlogin.orig/rlogin.c rlogin/rlogin.c
--- rlogin.orig/rlogin.c        2013-02-22 13:37:55.000000000 +0100
+++ rlogin/rlogin.c     2013-02-22 13:50:42.000000000 +0100
@@ -56,6 +56,7 @@ __RCSID("$NetBSD: rlogin.c,v 1.41 2011/0
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
+#include <netinet/tcp.h>
 
 #include <err.h>
 #include <errno.h>
@@ -73,7 +74,6 @@ __RCSID("$NetBSD: rlogin.c,v 1.41 2011/0
 
 #include "getport.h"
 
-
 #ifndef TIOCPKT_WINDOW
 #define        TIOCPKT_WINDOW  0x80
 #endif
@@ -134,7 +134,7 @@ main(int argc, char *argv[])
        struct termios tty;
        sigset_t smask;
        uid_t uid;
-       int argoff, ch, dflag, one;
+       int argoff, ch, dflag, Dflag, one;
        int i, len, len2;
        int family = AF_UNSPEC;
        char *host, *p, *user, *name, term[1024] = "network";
@@ -143,7 +143,7 @@ main(int argc, char *argv[])
        char *service = NULL;
        struct rlimit rlim;
 
-       argoff = dflag = 0;
+       argoff = dflag = Dflag = 0;
        one = 1;
        host = user = NULL;
        sp = NULL;
@@ -160,7 +160,7 @@ main(int argc, char *argv[])
                argoff = 1;
        }
 
-#define        OPTIONS "468dEe:l:p:"
+#define        OPTIONS "468DdEe:l:p:"
        while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1)
                switch(ch) {
                case '4':
@@ -172,6 +172,9 @@ main(int argc, char *argv[])
                case '8':
                        eight = 1;
                        break;
+               case 'D':
+                       Dflag = 1;
+                       break;
                case 'd':
                        dflag = 1;
                        break;
@@ -258,21 +261,23 @@ main(int argc, char *argv[])
        (void)sigaction(SIGURG, &sa, (struct sigaction *) 0);
        sa.sa_handler = writeroob;
        (void)sigaction(SIGUSR1, &sa, (struct sigaction *) 0);
-       
+
        /* don't dump core */
        rlim.rlim_cur = rlim.rlim_max = 0;
        if (setrlimit(RLIMIT_CORE, &rlim) < 0)
                warn("setrlimit");
 
        rem = rcmd_af(&host, sp->s_port, name, user, term, 0, family);
-
-
        if (rem < 0)
                exit(1);
 
        if (dflag &&
            setsockopt(rem, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) < 0)
                warn("setsockopt DEBUG (ignored)");
+        if (Dflag &&
+           setsockopt(rem, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) < 0)
+               warn("setsockopt NODELAY (ignored)");
+
     {
        struct sockaddr_storage ss;
        socklen_t sslen;
@@ -471,14 +476,14 @@ writer(void)
                                continue;
                        }
                        if (c != escapechar) {
-                                       (void)write(rem, &escapechar, 1);
+                               (void)write(rem, &escapechar, 1);
                        }
                }
 
-                       if (write(rem, &c, 1) == 0) {
-                               msg("line gone");
-                               break;
-                       }
+               if (write(rem, &c, 1) == 0) {
+                       msg("line gone");
+                       break;
+               }
 
                bol = CCEQ(deftty.c_cc[VKILL], c) ||
                    CCEQ(deftty.c_cc[VEOF], c) ||
@@ -559,7 +564,7 @@ sendwindow(void)
        wp->ws_xpixel = htons(winsize.ws_xpixel);
        wp->ws_ypixel = htons(winsize.ws_ypixel);
 
-               (void)write(rem, obuf, sizeof(obuf));
+       (void)write(rem, obuf, sizeof(obuf));
 }
 
 /*
@@ -689,8 +694,7 @@ reader(sigset_t *smask)
                rcvcnt = 0;
                rcvstate = READING;
 
-                       rcvcnt = read(rem, rcvbuf, sizeof (rcvbuf));
-
+               rcvcnt = read(rem, rcvbuf, sizeof (rcvbuf));
                if (rcvcnt == 0)
                        return (0);
                if (rcvcnt < 0) {
@@ -759,7 +763,6 @@ msg(const char *str)
        (void)fprintf(stderr, "rlogin: %s\r\n", str);
 }
 
-
 static void
 usage(void)
 {


Home | Main Index | Thread Index | Old Index