Finished the Linux side changes for the "Cleanup during library unload"

issue.
This commit is contained in:
Juan Carlos Luciani 2007-01-29 13:04:22 +00:00
parent b5a6a452e8
commit 57f18cef8c
4 changed files with 126 additions and 7 deletions

View File

@ -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);

View File

@ -291,6 +291,11 @@ extern
CasaStatus
InitializeAuthCache(void);
extern
void
UnInitializeAuthCache(void);
//
// Functions exported by config.c
//

View File

@ -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();
}
//++=======================================================================
//++=======================================================================
//++=======================================================================

View File

@ -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);
}
//++=======================================================================
//++=======================================================================
//++=======================================================================