Commit 3f9e522b authored by Ian Lynagh's avatar Ian Lynagh

Free thread local storage on shutdown

parent 64496ad6
......@@ -172,6 +172,7 @@ extern void closeMutex ( Mutex* pMut );
void newThreadLocalKey (ThreadLocalKey *key);
void *getThreadLocalVar (ThreadLocalKey *key);
void setThreadLocalVar (ThreadLocalKey *key, void *value);
void freeThreadLocalKey (ThreadLocalKey *key);
#else
......
......@@ -99,6 +99,9 @@ freeTaskManager (void)
}
all_tasks = NULL;
task_free_list = NULL;
#if defined(THREADED_RTS)
freeThreadLocalKey(&currentTaskKey);
#endif
RELEASE_LOCK(&sched_mutex);
}
......
......@@ -148,6 +148,15 @@ setThreadLocalVar (ThreadLocalKey *key, void *value)
}
}
void
freeThreadLocalKey (ThreadLocalKey *key)
{
int r;
if ((r = pthread_key_delete(key)) != 0) {
barf("freeThreadLocalKey: %s", strerror(r));
}
}
static void *
forkOS_createThreadWrapper ( void * entry )
{
......
......@@ -197,6 +197,17 @@ setThreadLocalVar (ThreadLocalKey *key, void *value)
}
}
void
freeThreadLocalKey (ThreadLocalKey *key)
{
BOOL r;
r = TlsFree(*key);
if (r == 0) {
DWORD dw = GetLastError();
barf("freeThreadLocalKey failed: %lu", dw);
}
}
static unsigned __stdcall
forkOS_createThreadWrapper ( void * entry )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment