From d56b95d9a213cb862aeb1f31b6f2c9078530f631 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 4 Jan 2004 10:39:03 +0000 Subject: [PATCH] avoid-long-windows-shell-timeouts-20040105 * 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 | 3 +++ src/WINNT/afsd/cm_conn.c | 20 +++++++++++--------- src/WINNT/afsd/cm_volume.c | 2 ++ src/WINNT/afsd/smb.c | 6 +++++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 84346f295..cf36cbda1 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -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; diff --git a/src/WINNT/afsd/cm_conn.c b/src/WINNT/afsd/cm_conn.c index 33e8daff0..97f6b3876 100644 --- a/src/WINNT/afsd/cm_conn.c +++ b/src/WINNT/afsd/cm_conn.c @@ -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; diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index 994e526c5..e2aed5e10 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -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; diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index 063c43db9..0be9cff9d 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -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 */ -- 2.39.5