Make +atExit method honor the shoudl clean up setting

This commit is contained in:
rfm 2024-11-19 18:10:07 +00:00
parent 691d1eaafe
commit 7965acc27b
4 changed files with 55 additions and 43 deletions

View file

@ -304,17 +304,20 @@ static NSMutableDictionary *privateKeyCache1 = nil;
+ (void) atExit
{
DESTROY(certificateListLock);
DESTROY(certificateListCache);
DESTROY(credentialsLock);
DESTROY(credentialsCache);
DESTROY(fileLock);
DESTROY(fileMap);
DESTROY(paramsLock);
DESTROY(paramsCache);
DESTROY(privateKeyLock);
DESTROY(privateKeyCache0);
DESTROY(privateKeyCache1);
if ([NSObject shouldCleanUp])
{
DESTROY(certificateListLock);
DESTROY(certificateListCache);
DESTROY(credentialsLock);
DESTROY(credentialsCache);
DESTROY(fileLock);
DESTROY(fileMap);
DESTROY(paramsLock);
DESTROY(paramsCache);
DESTROY(privateKeyLock);
DESTROY(privateKeyCache0);
DESTROY(privateKeyCache1);
}
}
+ (NSData*) dataForTLSFile: (NSString*)fileName

View file

@ -105,32 +105,35 @@ static SEL rlSel;
+ (void) atExit
{
id o;
/* The default placeholder array overrides -dealloc so we must get rid of
* it directly.
*/
o = defaultPlaceholderArray;
defaultPlaceholderArray = nil;
NSDeallocateObject(o);
/* Deallocate all the placeholders in the map before destroying it.
*/
GS_MUTEX_LOCK(placeholderLock);
if (placeholderMap)
if ([NSObject shouldCleanUp])
{
NSMapEnumerator mEnum = NSEnumerateMapTable(placeholderMap);
Class c;
id o;
id o;
while (NSNextMapEnumeratorPair(&mEnum, (void *)&c, (void *)&o))
{
NSDeallocateObject(o);
}
NSEndMapTableEnumeration(&mEnum);
DESTROY(placeholderMap);
/* The default placeholder array overrides -dealloc so we must get rid of
* it directly.
*/
o = defaultPlaceholderArray;
defaultPlaceholderArray = nil;
NSDeallocateObject(o);
/* Deallocate all the placeholders in the map before destroying it.
*/
GS_MUTEX_LOCK(placeholderLock);
if (placeholderMap)
{
NSMapEnumerator mEnum = NSEnumerateMapTable(placeholderMap);
Class c;
id o;
while (NSNextMapEnumeratorPair(&mEnum, (void *)&c, (void *)&o))
{
NSDeallocateObject(o);
}
NSEndMapTableEnumeration(&mEnum);
DESTROY(placeholderMap);
}
GS_MUTEX_UNLOCK(placeholderLock);
}
GS_MUTEX_UNLOCK(placeholderLock);
}
+ (void) initialize

View file

@ -720,13 +720,16 @@ static gs_mutex_t cache_lock = GS_MUTEX_INIT_STATIC;
+ (void) atExit
{
unsigned i;
for (i = 0; i < MAX_STANDARD_SETS; i++)
if ([NSObject shouldCleanUp])
{
GS_MUTEX_LOCK(cache_lock);
DESTROY(cache_set[i]);
GS_MUTEX_UNLOCK(cache_lock);
unsigned i;
for (i = 0; i < MAX_STANDARD_SETS; i++)
{
GS_MUTEX_LOCK(cache_lock);
DESTROY(cache_set[i]);
GS_MUTEX_UNLOCK(cache_lock);
}
}
}

View file

@ -116,9 +116,12 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
+ (void) atExit
{
DESTROY(locCenter);
DESTROY(pubCenter);
DESTROY(netCenter);
if ([NSObject shouldCleanUp])
{
DESTROY(locCenter);
DESTROY(pubCenter);
DESTROY(netCenter);
}
}
/**