[OpenAFS-devel] Patch to add a clienttimeout option for the fileserver

Robert Banz banz@umbc.edu
Fri, 16 Mar 2007 12:03:54 -0400


The following patch adds a "-clienttimeout" option to the fileserver,  
which takes one argument, a number of minutes to be used in aging out  
idle client connections.

The 2 hour default is too long in an environment where some hosts  
could be creating and abandoning client connections at a high rate  
(such as a fileserver that has clients that are running something  
nutty like this: http://www.umbc.edu/oit/iss/syscore/wiki/Mod_waklog).

This patch is against the 1.4.2 release.

diff -c -r openafs-1.4.2-dist/src/viced/host.c openafs-1.4.2- 
clienttimeout/src/viced/host.c
*** openafs-1.4.2-dist/src/viced/host.c Tue Sep  5 18:09:00 2006
--- openafs-1.4.2-clienttimeout/src/viced/host.c        Fri Mar 16  
11:44:21 2007
***************
*** 68,73 ****
--- 68,74 ----
   extern int CurrentConnections;
   extern int SystemId;
   extern int AnonymousID;
+ extern int clientTimeout;
   extern prlist AnonCPS;
   extern int LogLevel;
   extern struct afsconf_dir *confDir;   /* config dir object */
***************
*** 2626,2632 ****
        * 15 minutes
        */
       checktime = now - 15 * 60;
!     clientdeletetime = now - 120 * 60;        /* 2 hours ago */
       h_Enumerate(CheckHost, NULL);

   }                             /*h_CheckHosts */
--- 2627,2633 ----
        * 15 minutes
        */
       checktime = now - 15 * 60;
!     clientdeletetime = now - clientTimeout * 60;      /*  
configurable */
       h_Enumerate(CheckHost, NULL);

   }                             /*h_CheckHosts */
diff -c -r openafs-1.4.2-dist/src/viced/viced.c openafs-1.4.2- 
clienttimeout/src/viced/viced.c
*** openafs-1.4.2-dist/src/viced/viced.c        Fri Sep 15 19:19:28 2006
--- openafs-1.4.2-clienttimeout/src/viced/viced.c       Fri Mar 16  
12:00:43 2007
***************
*** 193,198 ****
--- 193,199 ----
   int abort_threshold = 10;
   int udpBufSize = 0;           /* UDP buffer size for receive */
   int sendBufSize = 16384;      /* send buffer size */
+ int clientTimeout = 120; /* 2 hours is the default */

   struct timeval tp;

***************
*** 758,763 ****
--- 759,765 ----
       strcat(buffer, "[-udpsize <size of socket buffer in bytes>] ");
       strcat(buffer, "[-sendsize <size of send buffer in bytes>] ");
       strcat(buffer, "[-abortthreshold <abort threshold>] ");
+     strcat(buffer, "[-clienttimeout <minutes>] ");
   /*   strcat(buffer, "[-enable_peer_stats] "); */
   /*   strcat(buffer, "[-enable_process_stats] "); */
       strcat(buffer, "[-help]\n");
***************
*** 1110,1115 ****
--- 1112,1129 ----
                      bufSize, 16384);
             else
                 sendBufSize = bufSize;
+     } else if (!strcmp(argv[i], "-clienttimeout" )) {
+         if ((i + 1) >= argc) {
+                   printf("You have to specify -clienttimeout  
<integer value>\n");
+                   return -1;
+           }
+           clientTimeout = atoi(argv[++i]);
+           if (clientTimeout < 1) {
+                   printf
+                   ("Error: clienttimeout %d is insane\n",
+                    clientTimeout);
+                   return -1;
+               }
         } else if (!strcmp(argv[i], "-enable_peer_stats")) {
             rx_enablePeerRPCStats();
         } else if (!strcmp(argv[i], "-enable_process_stats")) {
***************
*** 1157,1163 ****
         else if (strcmp(argv[i], "-mrafslogs") == 0) {
             /* set syslog logging flag */
             mrafsStyleLogs = 1;
!       }
         else {
             return (-1);
         }
--- 1171,1177 ----
         else if (strcmp(argv[i], "-mrafslogs") == 0) {
             /* set syslog logging flag */
             mrafsStyleLogs = 1;
!       }
         else {
             return (-1);
         }