]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
windows-restrict-timeouts-to-cifs-20060808
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 8 Aug 2006 17:36:48 +0000 (17:36 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 8 Aug 2006 17:36:48 +0000 (17:36 +0000)
If afsd takes longer than the cifs timeout to complete an operation
the cifs client may break the virtual circuit and create a new one.
this forces all file handles to be closed and locks to be released.
Try to prevent the circuit from being destroyed by allowing the
CIFS lanmanworkstation SessTimeout value to enforce upper limits
on the Conn and Hard Dead Timeouts.   Permit this automatic configuration
to be disabled by setting specific configuration values for timeouts
in the registry.

src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_conn.h

index 1b27595bd732d00e23486e09047ae5cc1223ccb5..6c92ae81fface967fdb46e657156793c02453555 100644 (file)
@@ -995,16 +995,6 @@ int afsd_InitCM(char **reasonP)
     if (rx_enable_process_stats)
         afsi_log("RX Process Statistics gathering is enabled");
 
-    dummyLen = sizeof(ConnDeadtimeout);
-    code = RegQueryValueEx(parmKey, "ConnDeadTimeout", NULL, NULL,
-                           (BYTE *) &ConnDeadtimeout, &dummyLen);
-    afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
-
-    dummyLen = sizeof(HardDeadtimeout);
-    code = RegQueryValueEx(parmKey, "HardDeadTimeout", NULL, NULL,
-                           (BYTE *) &HardDeadtimeout, &dummyLen);
-    afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
-
     dummyLen = sizeof(DWORD);
     code = RegQueryValueEx(parmKey, "daemonCheckDownInterval", NULL, NULL,
                            (BYTE *) &dwValue, &dummyLen);
index 35b348e049ff61f2335e2e8c971ffacb44adb95b..493261533b4685d73ce5a5237907ffd022132f41 100644 (file)
@@ -18,6 +18,7 @@
 #include <rx/rx.h>
 #include <rx/rxkad.h>
 #include <afs/unified_afs.h>
+#include <WINNT/afsreg.h>
 
 osi_rwlock_t cm_connLock;
 
@@ -39,10 +40,11 @@ void cm_PutConn(cm_conn_t *connp)
 
 void cm_InitConn(void)
 {
-       static osi_once_t once;
-       long code;
-       DWORD sessTimeout;
-       HKEY parmKey;
+    static osi_once_t once;
+    long code;
+    DWORD dwValue;
+    DWORD dummyLen;
+    HKEY parmKey;
         
     if (osi_Once(&once)) {
        lock_InitializeRWLock(&cm_connLock, "connection global lock");
@@ -58,25 +60,40 @@ void cm_InitConn(void)
                            0, KEY_QUERY_VALUE, &parmKey);
        if (code == ERROR_SUCCESS)
         {
-           DWORD dummyLen = sizeof(sessTimeout);
+           dummyLen = sizeof(DWORD);
            code = RegQueryValueEx(parmKey, LANMAN_WKS_SESSION_TIMEOUT, NULL, NULL, 
-                                  (BYTE *) &sessTimeout, &dummyLen);
+                                  (BYTE *) &dwValue, &dummyLen);
            if (code == ERROR_SUCCESS)
-            {
-                RDRtimeout = sessTimeout;
-           }
+                RDRtimeout = dwValue;
+           RegCloseKey(parmKey);
         }
 
-       afsi_log("lanmanworkstation : SessTimeout %d", sessTimeout);
-       if ( ConnDeadtimeout < RDRtimeout + 15 ) {
-           ConnDeadtimeout = RDRtimeout + 15;
-           afsi_log("ConnDeadTimeout increased to %d", ConnDeadtimeout);
-       }
-       if ( HardDeadtimeout < 2 * ConnDeadtimeout ) {
-           HardDeadtimeout = 2 * ConnDeadtimeout;
-           afsi_log("HardDeadTimeout increased to %d", HardDeadtimeout);
+       code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
+                            0, KEY_QUERY_VALUE, &parmKey);
+       if (code == ERROR_SUCCESS) {
+           dummyLen = sizeof(DWORD);
+           code = RegQueryValueEx(parmKey, "ConnDeadTimeout", NULL, NULL,
+                                   (BYTE *) &dwValue, &dummyLen);
+           if (code == ERROR_SUCCESS)
+                ConnDeadtimeout = dwValue;
+
+           dummyLen = sizeof(DWORD);
+           code = RegQueryValueEx(parmKey, "HardDeadTimeout", NULL, NULL,
+                                   (BYTE *) &dwValue, &dummyLen);
+           if (code == ERROR_SUCCESS)
+                HardDeadtimeout = dwValue;
+           afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
+           RegCloseKey(parmKey);
        }
 
+       afsi_log("lanmanworkstation : SessTimeout %d", RDRtimeout);
+       if (ConnDeadtimeout == 0)
+           ConnDeadtimeout = RDRtimeout / 2;
+       afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
+       if (HardDeadtimeout == 0)
+           HardDeadtimeout = RDRtimeout;
+       afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
+
        osi_EndOnce(&once);
     }
 }
index fb4548444eaf01b44c086370a59a0197dda87ca0..d0cf8ada6ea8070ecdfd11e6848a3c7ab21b1ca7 100644 (file)
@@ -11,8 +11,8 @@
 #define __CM_CONN_H_ENV__ 1
 
 #define        CM_CONN_DEFAULTRDRTIMEOUT       45
-#define CM_CONN_CONNDEADTIME           60
-#define CM_CONN_HARDDEADTIME        120
+#define CM_CONN_CONNDEADTIME            0
+#define CM_CONN_HARDDEADTIME             0
 
 extern unsigned short ConnDeadtimeout;
 extern unsigned short HardDeadtimeout;