summaryrefslogtreecommitdiff
path: root/pr/src/threads/combined/pruthr.c
diff options
context:
space:
mode:
Diffstat (limited to 'pr/src/threads/combined/pruthr.c')
-rw-r--r--pr/src/threads/combined/pruthr.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/pr/src/threads/combined/pruthr.c b/pr/src/threads/combined/pruthr.c
index 0025bcbb..26d9ee91 100644
--- a/pr/src/threads/combined/pruthr.c
+++ b/pr/src/threads/combined/pruthr.c
@@ -303,7 +303,7 @@ _PR_DecrActiveThreadCount(PRThread *thread)
static void
_PR_DestroyThread(PRThread *thread)
{
- _MD_FREE_LOCK(&thread->threadLock);
+ _PR_MD_FREE_LOCK(&thread->threadLock);
PR_DELETE(thread);
}
@@ -335,7 +335,7 @@ _PR_UserDestroyThread(PRThread *thread)
PR_DELETE(thread->privateData);
thread->tpdLength = 0;
}
- _MD_FREE_LOCK(&thread->threadLock);
+ _PR_MD_FREE_LOCK(&thread->threadLock);
if (thread->threadAllocatedOnStack == 1) {
_PR_MD_CLEAN_THREAD(thread);
/*
@@ -988,7 +988,7 @@ _PR_AttachThread(PRThreadType type, PRThreadPriority priority,
thread->stack = stack;
thread->state = _PR_RUNNING;
PR_INIT_CLIST(&thread->lockList);
- if (_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {
+ if (_PR_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {
PR_DELETE(thread);
return 0;
}
@@ -1248,6 +1248,14 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread(PRThreadType type,
top = (char*)((PRUptrdiff)top & ~0x3f);
}
#endif
+#if defined(GC_LEAK_DETECTOR)
+ /*
+ * sorry, it is not safe to allocate the thread on the stack,
+ * because we assign to this object before the GC can learn
+ * about this thread. we'll just leak thread objects instead.
+ */
+ thread = PR_NEW(PRThread);
+#endif
stack->thr = thread;
memset(thread, 0, sizeof(PRThread));
thread->threadAllocatedOnStack = 1;
@@ -1281,7 +1289,7 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread(PRThreadType type,
return NULL;
}
- if (_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {
+ if (_PR_MD_NEW_LOCK(&thread->threadLock) == PR_FAILURE) {
if (thread->threadAllocatedOnStack == 1)
_PR_FreeStack(thread->stack);
else {
@@ -1295,7 +1303,7 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread(PRThreadType type,
_PR_MD_INIT_CONTEXT(thread, top, _PR_UserRunThread, &status);
if (status == PR_FALSE) {
- _MD_FREE_LOCK(&thread->threadLock);
+ _PR_MD_FREE_LOCK(&thread->threadLock);
if (thread->threadAllocatedOnStack == 1)
_PR_FreeStack(thread->stack);
else {
@@ -1312,7 +1320,7 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread(PRThreadType type,
if (state == PR_JOINABLE_THREAD) {
thread->term = PR_NewCondVar(_pr_terminationCVLock);
if (thread->term == NULL) {
- _MD_FREE_LOCK(&thread->threadLock);
+ _PR_MD_FREE_LOCK(&thread->threadLock);
if (thread->threadAllocatedOnStack == 1)
_PR_FreeStack(thread->stack);
else {
@@ -1487,7 +1495,7 @@ void _PRI_DetachThread(void)
_PR_MD_SET_CURRENT_THREAD(NULL);
if (!me->threadAllocatedOnStack)
PR_DELETE(me->stack);
- _MD_FREE_LOCK(&me->threadLock);
+ _PR_MD_FREE_LOCK(&me->threadLock);
PR_DELETE(me);
}