Updated to only add non-success authtoken entries to the

cache if the time necessary to process them exceeds 30
seconds. With this change we make sure that non-successful
entries are added to the cache to deal with server
un-available issues.
This commit is contained in:
Juan Carlos Luciani 2007-06-12 16:51:18 +00:00
parent e9551385d0
commit ad7a069507

View File

@ -29,7 +29,9 @@
//===[ Type definitions ]================================================== //===[ Type definitions ]==================================================
#define DEFAULT_RETRY_LIFETIME 300 // seconds #define DEFAULT_RETRY_LIFETIME 300 // seconds
#define BAD_CACHE_TRIGER_TIME 30 // seconds
#define DEFAULT_ATS_PORT 2645 #define DEFAULT_ATS_PORT 2645
@ -661,8 +663,8 @@ ObtainAuthTokenInt(
bool setupHostEntries = true; bool setupHostEntries = true;
char *pHostNameAnd443 = NULL; char *pHostNameAnd443 = NULL;
char *pHostNameAnd2645 = NULL; char *pHostNameAnd2645 = NULL;
ATSHostEntry serviceHostEntry443 = {NULL, NULL, NULL, NULL, 0}; ATSHostEntry serviceHostEntry443 = {{NULL, NULL}, NULL, NULL, 0};
ATSHostEntry serviceHostEntry2645 = {NULL, NULL, NULL, NULL, 0}; ATSHostEntry serviceHostEntry2645 = {{NULL, NULL}, NULL, NULL, 0};
LIST_ENTRY *pListEntry; LIST_ENTRY *pListEntry;
ATSHostEntry *pHostEntryInUse; ATSHostEntry *pHostEntryInUse;
@ -734,6 +736,7 @@ ObtainAuthTokenInt(
// Initialize to retry in case of failure // Initialize to retry in case of failure
int cacheEntryLifetime = DEFAULT_RETRY_LIFETIME; int cacheEntryLifetime = DEFAULT_RETRY_LIFETIME;
bool advisedToRetry; bool advisedToRetry;
DWORD opStartTime = GetTickCount();
// Cache entry created, now try to obtain auth token from the CASA Server // Cache entry created, now try to obtain auth token from the CASA Server
pToken = NULL; pToken = NULL;
@ -760,23 +763,31 @@ ObtainAuthTokenInt(
&advisedToRetry); &advisedToRetry);
} }
// Add the entry to the cache if we did not fail due to authentication // Try to add the entry to the cache if we did not fail due
// failure. // to authentication failure.
if (CasaStatusCode(retStatus) != CASA_STATUS_AUTHENTICATION_FAILURE) if (CasaStatusCode(retStatus) != CASA_STATUS_AUTHENTICATION_FAILURE)
{ {
pCacheEntry = CreateAuthTokenCacheEntry(pServiceName, DWORD opEndTime = GetTickCount();
pNormalizedHostName,
pHostEntryInUse, // We only want to cache bad results if the operation took a
retStatus, // considerable amount of time.
pToken, if (CASA_SUCCESS(retStatus)
cacheEntryLifetime, || opEndTime >= (opStartTime + (BAD_CACHE_TRIGER_TIME * 1000)))
pCredStoreScope);
if (pCacheEntry)
{ {
// Release the cache entry if the resulting status is not successful pCacheEntry = CreateAuthTokenCacheEntry(pServiceName,
if (!CASA_SUCCESS(retStatus)) pNormalizedHostName,
pHostEntryInUse,
retStatus,
pToken,
cacheEntryLifetime,
pCredStoreScope);
if (pCacheEntry)
{ {
FreeAuthCacheEntry(pCacheEntry); // Release the cache entry if the resulting status is not successful
if (!CASA_SUCCESS(retStatus))
{
FreeAuthCacheEntry(pCacheEntry);
}
} }
} }
} }