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:
parent
e9551385d0
commit
ad7a069507
@ -31,6 +31,8 @@
|
||||
|
||||
#define DEFAULT_RETRY_LIFETIME 300 // seconds
|
||||
|
||||
#define BAD_CACHE_TRIGER_TIME 30 // seconds
|
||||
|
||||
#define DEFAULT_ATS_PORT 2645
|
||||
|
||||
#define LOG_FILE_NAME "\\casaauthtoken.log"
|
||||
@ -661,8 +663,8 @@ ObtainAuthTokenInt(
|
||||
bool setupHostEntries = true;
|
||||
char *pHostNameAnd443 = NULL;
|
||||
char *pHostNameAnd2645 = NULL;
|
||||
ATSHostEntry serviceHostEntry443 = {NULL, NULL, NULL, NULL, 0};
|
||||
ATSHostEntry serviceHostEntry2645 = {NULL, NULL, NULL, NULL, 0};
|
||||
ATSHostEntry serviceHostEntry443 = {{NULL, NULL}, NULL, NULL, 0};
|
||||
ATSHostEntry serviceHostEntry2645 = {{NULL, NULL}, NULL, NULL, 0};
|
||||
LIST_ENTRY *pListEntry;
|
||||
ATSHostEntry *pHostEntryInUse;
|
||||
|
||||
@ -734,6 +736,7 @@ ObtainAuthTokenInt(
|
||||
// Initialize to retry in case of failure
|
||||
int cacheEntryLifetime = DEFAULT_RETRY_LIFETIME;
|
||||
bool advisedToRetry;
|
||||
DWORD opStartTime = GetTickCount();
|
||||
|
||||
// Cache entry created, now try to obtain auth token from the CASA Server
|
||||
pToken = NULL;
|
||||
@ -760,9 +763,16 @@ ObtainAuthTokenInt(
|
||||
&advisedToRetry);
|
||||
}
|
||||
|
||||
// Add the entry to the cache if we did not fail due to authentication
|
||||
// failure.
|
||||
// Try to add the entry to the cache if we did not fail due
|
||||
// to authentication failure.
|
||||
if (CasaStatusCode(retStatus) != CASA_STATUS_AUTHENTICATION_FAILURE)
|
||||
{
|
||||
DWORD opEndTime = GetTickCount();
|
||||
|
||||
// We only want to cache bad results if the operation took a
|
||||
// considerable amount of time.
|
||||
if (CASA_SUCCESS(retStatus)
|
||||
|| opEndTime >= (opStartTime + (BAD_CACHE_TRIGER_TIME * 1000)))
|
||||
{
|
||||
pCacheEntry = CreateAuthTokenCacheEntry(pServiceName,
|
||||
pNormalizedHostName,
|
||||
@ -780,6 +790,7 @@ ObtainAuthTokenInt(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Release authentication token if present
|
||||
if (pToken)
|
||||
|
Loading…
Reference in New Issue
Block a user