Bug 871064: _PR_InitThreads() should not call PR_SetThreadPriority().
authorWan-Teh Chang <wtc@google.com>
Mon, 13 May 2013 16:16:30 -0700
changeset 4465 8a9fc0355b0992aa4cbe93e5fbf75d63a72d3d98
parent 4464 fb7fff159c8c4804e2603b579edb92541be8b3b5
child 4466 119d4ef3679ca1b0fce1182460c34194f53abd8a
push id16
push userwtc@google.com
push dateMon, 13 May 2013 23:19:34 +0000
bugs871064
Bug 871064: _PR_InitThreads() should not call PR_SetThreadPriority(). Assert that we only pass priority=PR_PRIORITY_NORMAL to _PR_InitThreads(). r=gsvelto.
pr/src/pthreads/ptthread.c
pr/src/threads/combined/pruthr.c
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -886,16 +886,18 @@ static void _pt_thread_death_internal(vo
 }  /* _pt_thread_death */
 
 void _PR_InitThreads(
     PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs)
 {
     int rv;
     PRThread *thred;
 
+    PR_ASSERT(priority == PR_PRIORITY_NORMAL);
+
 #ifdef _PR_NEED_PTHREAD_INIT
     /*
      * On BSD/OS (3.1 and 4.0), the pthread subsystem is lazily
      * initialized, but pthread_self() fails to initialize
      * pthreads and hence returns a null thread ID if invoked
      * by the primordial thread before any other pthread call.
      * So we explicitly initialize pthreads here.
      */
@@ -975,17 +977,16 @@ void _PR_InitThreads(
      * after the thread is joined. Therefore, threads that are joining
      * and holding PRThread references are actually holding pointers to
      * nothing.
      */
     rv = _PT_PTHREAD_KEY_CREATE(&pt_book.key, _pt_thread_death);
     PR_ASSERT(0 == rv);
     rv = pthread_setspecific(pt_book.key, thred);
     PR_ASSERT(0 == rv);    
-    PR_SetThreadPriority(thred, priority);
 }  /* _PR_InitThreads */
 
 #ifdef __GNUC__
 /*
  * GCC supports the constructor and destructor attributes as of
  * version 2.5.
  */
 static void _PR_Fini(void) __attribute__ ((destructor));
--- a/pr/src/threads/combined/pruthr.c
+++ b/pr/src/threads/combined/pruthr.c
@@ -60,16 +60,18 @@ static void _PR_InitializeRecycledThread
 static void _PR_UserRunThread(void);
 
 void _PR_InitThreads(PRThreadType type, PRThreadPriority priority,
     PRUintn maxPTDs)
 {
     PRThread *thread;
     PRThreadStack *stack;
 
+    PR_ASSERT(priority == PR_PRIORITY_NORMAL);
+
     _pr_terminationCVLock = PR_NewLock();
     _pr_activeLock = PR_NewLock();
 
 #ifndef HAVE_CUSTOM_USER_THREADS
     stack = PR_NEWZAP(PRThreadStack);
 #ifdef HAVE_STACK_GROWING_UP
     stack->stackTop = (char*) ((((long)&type) >> _pr_pageShift)
                   << _pr_pageShift);