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



The following reply was made to PR bin/47584; it has been noted by GNATS.

From: Steffen "Daode" Nurpmeso <sdaoden%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Subject: Re: bin/47584: rlogin(1): responsiveness could be better
Date: Fri, 22 Feb 2013 15:01:19 +0100

  |>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>
 =20
  #include <err.h>
  #include <errno.h>
 @@ -73,7 +74,6 @@ __RCSID("$NetBSD: rlogin.c,v 1.41 2011/0
 =20
  #include "getport.h"
 =20
 -
  #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 =3D AF_UNSPEC;
        char *host, *p, *user, *name, term[1024] =3D "network";
 @@ -143,7 +143,7 @@ main(int argc, char *argv[])
        char *service =3D NULL;
        struct rlimit rlim;
 =20
 -      argoff =3D dflag =3D 0;
 +      argoff =3D dflag =3D Dflag =3D 0;
        one =3D 1;
        host =3D user =3D NULL;
        sp =3D NULL;
 @@ -160,7 +160,7 @@ main(int argc, char *argv[])
                argoff =3D 1;
        }
 =20
 -#define       OPTIONS "468dEe:l:p:"
 +#define       OPTIONS "468DdEe:l:p:"
        while ((ch =3D getopt(argc - argoff, argv + argoff, OPTIONS)) !=3D -1)
                switch(ch) {
                case '4':
 @@ -172,6 +172,9 @@ main(int argc, char *argv[])
                case '8':
                        eight =3D 1;
                        break;
 +              case 'D':
 +                      Dflag =3D 1;
 +                      break;
                case 'd':
                        dflag =3D 1;
                        break;
 @@ -258,21 +261,23 @@ main(int argc, char *argv[])
        (void)sigaction(SIGURG, &sa, (struct sigaction *) 0);
        sa.sa_handler =3D writeroob;
        (void)sigaction(SIGUSR1, &sa, (struct sigaction *) 0);
 -=09
 +
        /* don't dump core */
        rlim.rlim_cur =3D rlim.rlim_max =3D 0;
        if (setrlimit(RLIMIT_CORE, &rlim) < 0)
                warn("setrlimit");
 =20
        rem =3D rcmd_af(&host, sp->s_port, name, user, term, 0, family);
 -
 -
        if (rem < 0)
                exit(1);
 =20
        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 !=3D escapechar) {
 -                                      (void)write(rem, &escapechar, 1);
 +                              (void)write(rem, &escapechar, 1);
                        }
                }
 =20
 -                      if (write(rem, &c, 1) =3D=3D 0) {
 -                              msg("line gone");
 -                              break;
 -                      }
 +              if (write(rem, &c, 1) =3D=3D 0) {
 +                      msg("line gone");
 +                      break;
 +              }
 =20
                bol =3D CCEQ(deftty.c_cc[VKILL], c) ||
                    CCEQ(deftty.c_cc[VEOF], c) ||
 @@ -559,7 +564,7 @@ sendwindow(void)
        wp->ws_xpixel =3D htons(winsize.ws_xpixel);
        wp->ws_ypixel =3D htons(winsize.ws_ypixel);
 =20
 -              (void)write(rem, obuf, sizeof(obuf));
 +      (void)write(rem, obuf, sizeof(obuf));
  }
 =20
  /*
 @@ -689,8 +694,7 @@ reader(sigset_t *smask)
                rcvcnt =3D 0;
                rcvstate =3D READING;
 =20
 -                      rcvcnt =3D read(rem, rcvbuf, sizeof (rcvbuf));
 -
 +              rcvcnt =3D read(rem, rcvbuf, sizeof (rcvbuf));
                if (rcvcnt =3D=3D 0)
                        return (0);
                if (rcvcnt < 0) {
 @@ -759,7 +763,6 @@ msg(const char *str)
        (void)fprintf(stderr, "rlogin: %s\r\n", str);
  }
 =20
 -
  static void
  usage(void)
  {
 


Home | Main Index | Thread Index | Old Index