Added code to allow us to un-initialize the library when it is unloaded. These changes allow library un-initialization to work for Windows. More code needs to be added to un-initialize the library under Linux.
This commit is contained in:
@@ -45,6 +45,9 @@ typedef struct _NormalizedHostNameCacheEntry
|
||||
|
||||
//===[ Global variables ]==================================================
|
||||
|
||||
static
|
||||
BOOLEAN hostNameNormalizationInitialized = FALSE;
|
||||
|
||||
// Normalized host name cache list head
|
||||
static
|
||||
LIST_ENTRY normalizedHostNameCacheListHead;
|
||||
@@ -64,6 +67,7 @@ char mechConfigFolder[MAX_PATH + sizeof(mechConfigFolderPartialPath)];
|
||||
// Path separator
|
||||
char pathCharString[] = "\\";
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
CasaStatus
|
||||
CreateUserMutex(
|
||||
@@ -585,11 +589,13 @@ InitializeHostNameNormalization(void)
|
||||
NULL);
|
||||
if (hNormalizedHostNameCacheMutex != NULL)
|
||||
{
|
||||
hostNameNormalizationInitialized = TRUE;
|
||||
retStatus = CASA_STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-InitializeHostNameNormalization- CreateMutex failed, error = %d\n", GetLastError());
|
||||
WSACleanup();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -603,6 +609,63 @@ InitializeHostNameNormalization(void)
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
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)
|
||||
{
|
||||
// Un-initialize winsock
|
||||
WSACleanup();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
//++=======================================================================
|
||||
//++=======================================================================
|
||||
|
||||
Reference in New Issue
Block a user