windows-set-rx-dead-time-20080715
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 16 Jul 2008 05:43:06 +0000 (05:43 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 16 Jul 2008 05:43:06 +0000 (05:43 +0000)
LICENSE MIT

No longer set the rx_SetConnDeadTime and rx_SetConnHardDeadTime to
the remaining request SMB RDR timeout within cm_ConnByMServers().
There are not per-call timeouts so simultaneous requests on the same
connection will race with each other either resulting in premature
timeouts or significantly extended timeouts.

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

index 5d5b277..9b5fada 100644 (file)
@@ -76,34 +76,40 @@ void cm_InitConn(void)
            dummyLen = sizeof(DWORD);
            code = RegQueryValueEx(parmKey, "ConnDeadTimeout", NULL, NULL,
                                    (BYTE *) &dwValue, &dummyLen);
-           if (code == ERROR_SUCCESS)
+           if (code == ERROR_SUCCESS) {
                 ConnDeadtimeout = (unsigned short)dwValue;
-
+                afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
+            }
            dummyLen = sizeof(DWORD);
            code = RegQueryValueEx(parmKey, "HardDeadTimeout", NULL, NULL,
                                    (BYTE *) &dwValue, &dummyLen);
-           if (code == ERROR_SUCCESS)
+           if (code == ERROR_SUCCESS) {
                 HardDeadtimeout = (unsigned short)dwValue;
-           afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
-
+                afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
+            }
            dummyLen = sizeof(DWORD);
            code = RegQueryValueEx(parmKey, "IdleDeadTimeout", NULL, NULL,
                                    (BYTE *) &dwValue, &dummyLen);
-           if (code == ERROR_SUCCESS)
+           if (code == ERROR_SUCCESS) {
                 IdleDeadtimeout = (unsigned short)dwValue;
-           afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
-
+                afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
+            }
             RegCloseKey(parmKey);
        }
 
        afsi_log("lanmanworkstation : SessTimeout %u", RDRtimeout);
-       if (ConnDeadtimeout == 0)
+       if (ConnDeadtimeout == 0) {
            ConnDeadtimeout = (unsigned short) (RDRtimeout / 2);
-       afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
-       if (HardDeadtimeout == 0)
+            afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
+        }
+       if (HardDeadtimeout == 0) {
            HardDeadtimeout = (unsigned short) RDRtimeout;
-       afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
-
+            afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
+        }
+       if (ConnDeadtimeout == 0) {
+           IdleDeadtimeout = (unsigned short) RDRtimeout;
+            afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
+        }
        osi_EndOnce(&once);
     }
 }
@@ -764,8 +770,9 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
     cm_server_t *tsp;
     long firstError = 0;
     int someBusy = 0, someOffline = 0, allOffline = 1, allBusy = 1, allDown = 1;
+#ifdef SET_RX_TIMEOUTS_TO_TIMELEFT
     long timeUsed, timeLeft, hardTimeLeft;
-
+#endif
     *connpp = NULL;
 
     if (serversp == NULL) {
@@ -773,11 +780,13 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
        return CM_ERROR_ALLDOWN;
     }
 
+#ifdef SET_RX_TIMEOUTS_TO_TIMELEFT
     timeUsed = (GetTickCount() - reqp->startTime) / 1000;
         
     /* leave 5 seconds margin of safety */
     timeLeft =  ConnDeadtimeout - timeUsed - 5;
     hardTimeLeft = HardDeadtimeout - timeUsed - 5;
+#endif
 
     lock_ObtainRead(&cm_serverLock);
     for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
@@ -811,6 +820,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
                 code = cm_ConnByServer(tsp, usersp, connpp);
                 if (code == 0) {        /* cm_CBS only returns 0 */
                     cm_PutServer(tsp);
+#ifdef SET_RX_TIMEOUTS_TO_TIMELEFT
                     /* Set RPC timeout */
                     if (timeLeft > ConnDeadtimeout)
                         timeLeft = ConnDeadtimeout;
@@ -822,6 +832,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
                     rx_SetConnDeadTime((*connpp)->callp, timeLeft);
                     rx_SetConnHardDeadTime((*connpp)->callp, (u_short) hardTimeLeft);
                     lock_ReleaseMutex(&(*connpp)->mx);
+#endif
                     return 0;
                 }
                 
index 30121f3..952c33b 100644 (file)
@@ -13,7 +13,7 @@
 #define        CM_CONN_DEFAULTRDRTIMEOUT       45
 #define CM_CONN_CONNDEADTIME            0
 #define CM_CONN_HARDDEADTIME             0
-#define CM_CONN_IDLEDEADTIME            30
+#define CM_CONN_IDLEDEADTIME             0
 
 extern unsigned short ConnDeadtimeout;
 extern unsigned short HardDeadtimeout;