From 41008a077e4645c77575f5993cd6f1cbb7622b18 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 10 Mar 2007 15:50:07 +0000 Subject: [PATCH] DEVEL15-windows-afsd-nat-handling-20070310 Improve cache manager performance behind NATs: * drop cm_daemonCheckUpInterval from 10 minutes to 4 minutes to bring it under the minimum recommended default port mapping idle timeout value for NATs * when a timeout on an rx connection occurs, retry the request once after forcing a new rx connection. If there was a NAT and the port mapping changed, the server would respond to the original addr:port associated with the rx connection. Forcing a new connection will allow the request to be responded to if the server is accessible. This should eliminate the UP-DOWN-UP-DOWN bouncing that user's have seen when working from behind a NAT. (cherry picked from commit f1862d783a610d85a258aaee1d00aff26f348223) --- src/WINNT/afsd/cm_conn.c | 17 +++++++++++------ src/WINNT/afsd/cm_conn.h | 1 + src/WINNT/afsd/cm_daemon.c | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/WINNT/afsd/cm_conn.c b/src/WINNT/afsd/cm_conn.c index 28ff219b2..23d617a78 100644 --- a/src/WINNT/afsd/cm_conn.c +++ b/src/WINNT/afsd/cm_conn.c @@ -168,6 +168,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp, long timeUsed, timeLeft; long code; char addr[16]; + int forcing_new = 0; osi_Log2(afsd_logp, "cm_Analyze connp 0x%p, code 0x%x", connp, errorCode); @@ -195,10 +196,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp, lock_ReleaseWrite(&cm_callbackLock); } - /* If not allowed to retry, don't */ - if (reqp->flags & CM_REQ_NORETRY) - goto out; - /* if timeout - check that it did not exceed the HardDead timeout * and retry */ @@ -487,7 +484,12 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp, else if (errorCode >= -64 && errorCode < 0) { /* mark server as down */ lock_ObtainMutex(&serverp->mx); - serverp->flags |= CM_SERVERFLAG_DOWN; + if (reqp->flags & CM_REQ_NEW_CONN_FORCED) + serverp->flags |= CM_SERVERFLAG_DOWN; + else { + reqp->flags |= CM_REQ_NEW_CONN_FORCED; + forcing_new = 1; + } lock_ReleaseMutex(&serverp->mx); cm_ForceNewConnections(serverp); if ( timeLeft > 2 ) @@ -611,7 +613,10 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp, } } - if (retry && dead_session) + /* If not allowed to retry, don't */ + if (!forcing_new && (reqp->flags & CM_REQ_NORETRY)) + retry = 0; + else if (retry && dead_session) retry = 0; out: diff --git a/src/WINNT/afsd/cm_conn.h b/src/WINNT/afsd/cm_conn.h index 79a9da108..5f27504a4 100644 --- a/src/WINNT/afsd/cm_conn.h +++ b/src/WINNT/afsd/cm_conn.h @@ -43,6 +43,7 @@ typedef struct cm_req { /* flags in cm_req structure */ #define CM_REQ_NORETRY 0x1 +#define CM_REQ_NEW_CONN_FORCED 0x2 /* * Vice2 error codes diff --git a/src/WINNT/afsd/cm_daemon.c b/src/WINNT/afsd/cm_daemon.c index c6c351e11..892a65560 100644 --- a/src/WINNT/afsd/cm_daemon.c +++ b/src/WINNT/afsd/cm_daemon.c @@ -31,7 +31,7 @@ /* in seconds */ long cm_daemonCheckDownInterval = 180; -long cm_daemonCheckUpInterval = 600; +long cm_daemonCheckUpInterval = 240; long cm_daemonCheckVolInterval = 3600; long cm_daemonCheckCBInterval = 60; long cm_daemonCheckLockInterval = 60; -- 2.39.5