]> git.saurik.com Git - apple/libpthread.git/blobdiff - src/pthread.c
libpthread-218.60.3.tar.gz
[apple/libpthread.git] / src / pthread.c
index 1377429d31440bb31661064da0d857158b02b53f..4380326f6be9a8fcbdbe3fe3f0aa9be14866597f 100644 (file)
@@ -2204,9 +2204,13 @@ _pthread_wqthread(pthread_t self, mach_port_t kport, void *stacklowaddr, void *k
 
 thexit:
        {
-               // Reset QoS to something low for the cleanup process
-               pthread_priority_t priority = _pthread_priority_make_newest(WQ_THREAD_CLEANUP_QOS, 0, 0);
-               _pthread_setspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_QOS_CLASS, priority);
+               pthread_priority_t current_priority = _pthread_getspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_QOS_CLASS);
+               if ((current_priority & _PTHREAD_PRIORITY_EVENT_MANAGER_FLAG) ||
+                       (_pthread_priority_get_qos_newest(current_priority) > WQ_THREAD_CLEANUP_QOS)) {
+                       // Reset QoS to something low for the cleanup process
+                       pthread_priority_t priority = _pthread_priority_make_newest(WQ_THREAD_CLEANUP_QOS, 0, 0);
+                       _pthread_setspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_QOS_CLASS, priority);
+               }
        }
 
        _pthread_exit(self, NULL);