avoid-long-windows-shell-timeouts-20040105
authorJeffrey Altman <jaltman@mit.edu>
Sun, 4 Jan 2004 10:39:03 +0000 (10:39 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 4 Jan 2004 10:39:03 +0000 (10:39 +0000)
 * cm_conn.c: assume that if all of the servers for a cell are DOWN
   that there is NOSUCHVOLUME.  We can't return TIMEDOUT because
   this assumes there is a server which is up and the windows shell
   will in turn continue to try to reach it for several minutes on
   each refresh.  Of course, each refresh occurs more frequently
   than the timeouts.

   We can't return ALLOFFLINE because that in turn results in
   an attempt to cm_ForceUpdateVolume() will a NULL (cm_fid_t *).
   That in turn causes a null reference and a crash.

 * cm_volume.c: place a check in cm_ForceUpdateVolume() to return
   without performing its job if there is no (cm_fid_t *) value.
   Unfortunately, this in a ALLOFFLINE situation places the
   service into an infinite loop.

   Question: why is cm_ForceUpdateVolume() ever being called with
   a NULL parameter for the (cm_fid_t *)?

 * cm_smb.c: change the NTStatus for CM_ERROR_NOIPC to Remote
   Resources instead of Access Denied.

 * cm_buf.c: add a debugging statement

src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_volume.c
src/WINNT/afsd/smb.c

index 84346f2..cf36cbd 100644 (file)
@@ -401,6 +401,9 @@ long buf_AddBuffers(long nbuffers)
        HANDLE hm;
        long cs;
 
+    afsi_log("%d buffers being added to the existing cache of size %d",
+              nbuffers, buf_nbuffers);
+
        /*
         * Cache file mapping constrained by
         * system allocation granularity;
index 33e8daf..97f6b38 100644 (file)
@@ -222,9 +222,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
        /* special codes:  missing volumes */
        if (errorCode == VNOVOL || errorCode == VMOVED || errorCode == VOFFLINE
            || errorCode == VSALVAGE || errorCode == VNOSERVICE) {
-               long newSum;
-               int same;
-
                /* Log server being offline for this volume */
                osi_Log4(afsd_logp, "cm_Analyze found server %d.%d.%d.%d marked offline for a volume",
                         ((serverp->addr.sin_addr.s_addr & 0xff)),
@@ -321,7 +318,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
        cm_serverRef_t *tsrp;
         cm_server_t *tsp;
         long firstError = 0;
-       int someBusy = 0, someOffline = 0;
+       int someBusy = 0, someOffline = 0, allDown = 1;
        long timeUsed, timeLeft, hardTimeLeft;
 #ifdef DJGPP
         struct timeval now;
@@ -352,6 +349,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
         tsp->refCount++;
         lock_ReleaseWrite(&cm_serverLock);
         if (!(tsp->flags & CM_SERVERFLAG_DOWN)) {
+            allDown = 0;
             if (tsrp->status == busy)
                 someBusy = 1;
             else if (tsrp->status == offline)
@@ -379,19 +377,23 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
                 if (firstError == 0) 
                     firstError = code;
             }
-        }
+               } 
         lock_ObtainWrite(&cm_serverLock);
         osi_assert(tsp->refCount-- > 0);
     }   
 
        lock_ReleaseWrite(&cm_serverLock);
        if (firstError == 0) {
-               if (someBusy) firstError = CM_ERROR_ALLBUSY;
-               else if (someOffline) firstError = CM_ERROR_ALLOFFLINE;
-               else if (serversp) firstError = CM_ERROR_TIMEDOUT;
+               if (someBusy) 
+                       firstError = CM_ERROR_ALLBUSY;
+               else if (someOffline) 
+                       firstError = CM_ERROR_ALLOFFLINE;
+               else if (!allDown && serversp) 
+                       firstError = CM_ERROR_TIMEDOUT;
                /* Only return CM_ERROR_NOSUCHVOLUME if there are no
                   servers for this volume */
-               else firstError = CM_ERROR_NOSUCHVOLUME;
+               else 
+                       firstError = CM_ERROR_NOSUCHVOLUME;
        }
        osi_Log1(afsd_logp, "cm_ConnByMServers returning %x", firstError);
     return firstError;
index 994e526..e2aed5e 100644 (file)
@@ -264,6 +264,8 @@ void cm_ForceUpdateVolume(cm_fid_t *fidp, cm_user_t *userp, cm_req_t *reqp)
        cm_volume_t *volp;
        long code;
 
+       if (!fidp) return;
+
        cellp = cm_FindCellByID(fidp->cell);
        if (!cellp) return;
 
index 063c43d..0be9cff 100644 (file)
@@ -1811,7 +1811,7 @@ void smb_MapNTError(long code, unsigned long *NTStatusp)
                NTStatus = 0xC000000FL; /* No such file */
         }
         else if (code == CM_ERROR_TIMEDOUT) {
-               NTStatus = 0xC00000CFL; /* Paused */
+            NTStatus = 0xC00000CFL;    /* Sharing Paused */
         }
         else if (code == CM_ERROR_RETRY) {
                NTStatus = 0xC000022DL; /* Retry */
@@ -1862,7 +1862,11 @@ void smb_MapNTError(long code, unsigned long *NTStatusp)
                NTStatus = 0xC00000CCL; /* Bad network name */
        }
        else if (code == CM_ERROR_NOIPC) {
+#ifdef COMMENT
                NTStatus = 0xC0000022L; /* Access Denied */
+#else
+        NTStatus = 0xC000013DL; /* Remote Resources */
+#endif
        }
        else if (code == CM_ERROR_CLOCKSKEW) {
                NTStatus = 0xC0000133L; /* Time difference at DC */