Subject: a better timeout patch

From: Darrell Fuhriman <[email-masked]>
Date: Tue, 24 Oct 1995 16:16:20 -0700 (PDT)

All right, I mentioned before that I wasn't happy with the previous 
timeout patch I sent out, so I rethought it and decided to use SO_KEEPALIVE.

*Important*  This patch has not been extensively tested, and only on SunOS 
4.1.4.  There had been enough complaints, that I thought I'd send it out 
and let you all beat on it.  :)   It is against 2.4.2-beta-7.  

Use at your own risk, I make no claims that it will work on *any* 
platform, including 4.1.4.

The default tcp_keepidle is 14400 seconds.  This is most certainly
excessive, so you can turn it down with netconfig [available at
ftp.ucsd.edu:/pub/csl/netconfig] (on SunOS 4.1.4 at least..  Solaris uses
ndd). 

For instance:  

netconfig tcp_keepidle 900

You'll need to put that in your startup files, BTW.

I would really appreciate hearing about successes and certainly about 
failures.

Good luck.

Darrell Fuhriman
Teleport System Administration

*** wu-ftpd-2.4.2-beta-7/src/ftpd.c     Mon Oct 23 00:53:18 1995
--- wu-ftpd-2.4.2-beta-7.mod/src/ftpd.c Tue Oct 24 14:42:26 1995
***************
*** 529,535 ****
  
      /* Try to handle urgent data inline */
  #ifdef SO_OOBINLINE
!     if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(int)) < 0)
          syslog(LOG_ERR, "setsockopt (SO_OOBINLINE): %m");
  #endif
  
--- 529,535 ----
  
      /* Try to handle urgent data inline */
  #ifdef SO_OOBINLINE
!     if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(int), SO_KEEPALIVE,  (char *)&on, sizeof(int)) < 0) 
          syslog(LOG_ERR, "setsockopt (SO_OOBINLINE): %m");
  #endif
  
***************
*** 651,657 ****
  int sig;
  #endif
  {
!     syslog(LOG_ERR, "exiting on signal %d: %s", sig, sys_siglist[sig] );
      chdir("/");
      signal(SIGIOT, SIG_DFL);
      signal(SIGILL, SIG_DFL);
--- 651,657 ----
  int sig;
  #endif
  {
!     syslog(LOG_ERR, "exiting on signal %d: %s", sig, strerror(sig) );
      chdir("/");
      signal(SIGIOT, SIG_DFL);
      signal(SIGILL, SIG_DFL);
***************
*** 1934,1941 ****
      s = socket(AF_INET, SOCK_STREAM, 0);
      if (s < 0)
          goto bad;
!     if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
!                    (char *) &on, sizeof(on)) < 0)
          goto bad;
      /* anchor socket to avoid multi-homing problems */
      data_source.sin_family = AF_INET;
--- 1934,1941 ----
      s = socket(AF_INET, SOCK_STREAM, 0);
      if (s < 0)
          goto bad;
!     if (setsockopt(s, SOL_SOCKET,  SO_REUSEADDR,
!                    (char *) &on, sizeof(on), SO_KEEPALIVE, (char *) &on, sizeof(on)) < 0)
          goto bad;
      /* anchor socket to avoid multi-homing problems */
      data_source.sin_family = AF_INET;

---

From: Darrell Fuhriman <[email-masked]>
Date: Tue, 24 Oct 1995 23:07:14 -0700 (PDT)

> *Important*  This patch has not been extensively tested, and only on SunOS 

All right.. I was hasty.  It doesn't work as well as the previous patch 
(but seems to work better than nothing.)

I'll look into it a little more and see what I can come up with.  *sigh*

Darrell Fuhriman