diff --git a/CASA-auth-token/client/library/cache.c b/CASA-auth-token/client/library/cache.c index 2e68b4c5..30f128db 100644 --- a/CASA-auth-token/client/library/cache.c +++ b/CASA-auth-token/client/library/cache.c @@ -47,7 +47,7 @@ typedef struct _WrapperAuthCacheEntry //===[ Global variables ]================================================== static -BOOLEAN g_authCacheInitialized = FALSE; +bool g_authCacheInitialized = false; HANDLE g_hCASAContext; @@ -675,7 +675,7 @@ InitializeAuthCache() } else { - g_authCacheInitialized = TRUE; + g_authCacheInitialized = true; retStatus = CASA_STATUS_SUCCESS; } @@ -687,7 +687,7 @@ InitializeAuthCache() //++======================================================================= void -UnInitializeAuthCache() +UnInitializeAuthCache(void) // // Arguments: // @@ -700,9 +700,6 @@ UnInitializeAuthCache() // L2 //=======================================================================-- { - CasaStatus retStatus; - SSCS_SECRETSTORE_T ssId; - DbgTrace(1, "-UnInitializeAuthCache- Start\n", 0); // Proceed if initialized @@ -715,7 +712,7 @@ UnInitializeAuthCache() // Forget about being initialized g_hCASAContext = NULL; - g_authCacheInitialized = FALSE; + g_authCacheInitialized = false; } DbgTrace(1, "-UnInitializeAuthCache- End\n", 0); diff --git a/CASA-auth-token/client/library/internal.h b/CASA-auth-token/client/library/internal.h index e300628b..9d9412fb 100644 --- a/CASA-auth-token/client/library/internal.h +++ b/CASA-auth-token/client/library/internal.h @@ -291,6 +291,11 @@ extern CasaStatus InitializeAuthCache(void); +extern +void +UnInitializeAuthCache(void); + + // // Functions exported by config.c // diff --git a/CASA-auth-token/client/library/linux/platform.c b/CASA-auth-token/client/library/linux/platform.c index fe8dbe00..5d7ff0da 100644 --- a/CASA-auth-token/client/library/linux/platform.c +++ b/CASA-auth-token/client/library/linux/platform.c @@ -100,6 +100,9 @@ LIST_ENTRY normalizedHostNameCacheListHead; static pthread_mutex_t g_hNormalizedHostNameCacheMutex = PTHREAD_MUTEX_INITIALIZER; +static +bool hostNameNormalizationInitialized = false; + // Client configuration file folder char clientConfigFolder[] = "/etc/CASA/authtoken/client"; @@ -832,12 +835,88 @@ InitializeHostNameNormalization(void) // Initialize the cache list head InitializeListHead(&normalizedHostNameCacheListHead); + // Remember + hostNameNormalizationInitialized = true; + DbgTrace(1, "-InitializeHostNameNormalization- End, retStatus = %08X\n", retStatus); return retStatus; } +//++======================================================================= +void +UnInitializeHostNameNormalization(void) +// +// Arguments: +// +// Returns: +// +// Abstract: +// +// Notes: +// +// L2 +//=======================================================================-- +{ + LIST_ENTRY *pListEntry; + NormalizedHostNameCacheEntry *pEntry = NULL; + + DbgTrace(1, "-UnInitializeHostNameNormalization- Start\n", 0); + + // Proceed if initialization succeeded + if (hostNameNormalizationInitialized) + { + // Free up any normalized host names in our cache + pListEntry = normalizedHostNameCacheListHead.Flink; + while (pListEntry != &normalizedHostNameCacheListHead) + { + // Get pointer to the entry + pEntry = CONTAINING_RECORD(pListEntry, NormalizedHostNameCacheEntry, listEntry); + + // Remove the entry from the list + RemoveEntryList(pListEntry); + + // Free the entry + if (pEntry->pHostName) + free(pEntry->pHostName); + + if (pEntry->pNormalizedHostName) + free(pEntry->pNormalizedHostName); + + free(pEntry); + + // Try to go to the next entry + pListEntry = normalizedHostNameCacheListHead.Flink; + } + + // Forget about being initialized + hostNameNormalizationInitialized = false; + } + + DbgTrace(1, "-UnInitializeHostNameNormalization- End", 0); +} + + +//++======================================================================= +void __attribute__ ((destructor)) +Lib_fini(void) +// +// Arguments: +// +// Returns: +// +// Abstract: +// +// Notes: +// +// L2 +//=======================================================================-- +{ + UnInitializeLibrary(); +} + + //++======================================================================= //++======================================================================= //++======================================================================= diff --git a/CASA-auth-token/client/library/linux/rpc.c b/CASA-auth-token/client/library/linux/rpc.c index f5d0998f..62885251 100644 --- a/CASA-auth-token/client/library/linux/rpc.c +++ b/CASA-auth-token/client/library/linux/rpc.c @@ -46,6 +46,9 @@ CleanupOSSLSupport(void); //===[ Global variables ]================================================== +static +bool g_rpcInitialized = false; + //++======================================================================= size_t @@ -566,6 +569,7 @@ InitializeRpc(void) else { // Success + g_rpcInitialized = true; retStatus = CASA_STATUS_SUCCESS; } } @@ -580,6 +584,40 @@ InitializeRpc(void) } +//++======================================================================= +void +UnInitializeRpc(void) +// +// Arguments: +// +// Returns: +// +// Abstract: +// +// Notes: +// +// L2 +//=======================================================================-- +{ + DbgTrace(1, "-UnInitializeRpc- Start\n", 0); + + // Only try to cleanup if we were initialized + if (g_rpcInitialized) + { + // Cleanup libcurl + curl_global_cleanup(); + + // Cleanup OpenSSL support + CleanupOSSLSupport(); + + // Forget about having been initialized + g_rpcInitialized = false; + } + + DbgTrace(1, "-UnInitializeRpc- End\n", 0); +} + + //++======================================================================= //++======================================================================= //++=======================================================================