From f1862d783a610d85a258aaee1d00aff26f348223 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 10 Mar 2007 15:48:01 +0000 Subject: [PATCH] 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. --- 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 d6fb7c341..d86862f79 100644 --- a/src/WINNT/afsd/cm_conn.c +++ b/src/WINNT/afsd/cm_conn.c @@ -162,6 +162,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); @@ -189,10 +190,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 */ @@ -458,7 +455,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 ) @@ -582,7 +584,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 0ab8bd565..d95f13888 100644 --- a/src/WINNT/afsd/cm_daemon.c +++ b/src/WINNT/afsd/cm_daemon.c @@ -27,7 +27,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