Loading libs/binder/IPCThreadState.cpp +18 −22 Original line number Diff line number Diff line Loading @@ -334,7 +334,6 @@ static pthread_mutex_t gTLSMutex = PTHREAD_MUTEX_INITIALIZER; LIBBINDER_IGNORE_END() static std::atomic<bool> gHaveTLS(false); static pthread_key_t gTLS = 0; static std::atomic<bool> gShutdown = false; static std::atomic<bool> gDisableBackgroundScheduling = false; IPCThreadState* IPCThreadState::self() Loading @@ -347,12 +346,6 @@ restart: return new IPCThreadState; } // Racey, heuristic test for simultaneous shutdown. if (gShutdown.load(std::memory_order_relaxed)) { ALOGW("Calling IPCThreadState::self() during shutdown is dangerous, expect a crash.\n"); return nullptr; } pthread_mutex_lock(&gTLSMutex); if (!gHaveTLS.load(std::memory_order_relaxed)) { int key_create_value = pthread_key_create(&gTLS, threadDestructor); Loading @@ -378,21 +371,24 @@ IPCThreadState* IPCThreadState::selfOrNull() return nullptr; } void IPCThreadState::shutdown() { gShutdown.store(true, std::memory_order_relaxed); if (gHaveTLS.load(std::memory_order_acquire)) { // XXX Need to wait for all thread pool threads to exit! IPCThreadState* st = (IPCThreadState*)pthread_getspecific(gTLS); if (st) { delete st; pthread_setspecific(gTLS, nullptr); } pthread_key_delete(gTLS); gHaveTLS.store(false, std::memory_order_release); } } // This code used to be responsible for deleting the TLS, but we keep it // forever, since binder threads would often race process destruction. // b/77934844. Keeping a few lines here for visibility of the history. // IPCThreadState is actually stored in threadDestructor. // // void IPCThreadState::shutdown() // { // if (gHaveTLS.load(std::memory_order_acquire)) { // // XXX Need to wait for all thread pool threads to exit! // IPCThreadState* st = (IPCThreadState*)pthread_getspecific(gTLS); // if (st) { // delete st; // pthread_setspecific(gTLS, nullptr); // } // pthread_key_delete(gTLS); // gHaveTLS.store(false, std::memory_order_release); // } // } void IPCThreadState::disableBackgroundScheduling(bool disable) { Loading libs/binder/include/binder/IPCThreadState.h +0 −2 Original line number Diff line number Diff line Loading @@ -180,8 +180,6 @@ public: [[nodiscard]] status_t addFrozenStateChangeCallback(int32_t handle, BpBinder* proxy); [[nodiscard]] status_t removeFrozenStateChangeCallback(int32_t handle, BpBinder* proxy); LIBBINDER_EXPORTED static void shutdown(); // Call this to disable switching threads to background scheduling when // receiving incoming IPC calls. This is specifically here for the // Android system process, since it expects to have background apps calling Loading Loading
libs/binder/IPCThreadState.cpp +18 −22 Original line number Diff line number Diff line Loading @@ -334,7 +334,6 @@ static pthread_mutex_t gTLSMutex = PTHREAD_MUTEX_INITIALIZER; LIBBINDER_IGNORE_END() static std::atomic<bool> gHaveTLS(false); static pthread_key_t gTLS = 0; static std::atomic<bool> gShutdown = false; static std::atomic<bool> gDisableBackgroundScheduling = false; IPCThreadState* IPCThreadState::self() Loading @@ -347,12 +346,6 @@ restart: return new IPCThreadState; } // Racey, heuristic test for simultaneous shutdown. if (gShutdown.load(std::memory_order_relaxed)) { ALOGW("Calling IPCThreadState::self() during shutdown is dangerous, expect a crash.\n"); return nullptr; } pthread_mutex_lock(&gTLSMutex); if (!gHaveTLS.load(std::memory_order_relaxed)) { int key_create_value = pthread_key_create(&gTLS, threadDestructor); Loading @@ -378,21 +371,24 @@ IPCThreadState* IPCThreadState::selfOrNull() return nullptr; } void IPCThreadState::shutdown() { gShutdown.store(true, std::memory_order_relaxed); if (gHaveTLS.load(std::memory_order_acquire)) { // XXX Need to wait for all thread pool threads to exit! IPCThreadState* st = (IPCThreadState*)pthread_getspecific(gTLS); if (st) { delete st; pthread_setspecific(gTLS, nullptr); } pthread_key_delete(gTLS); gHaveTLS.store(false, std::memory_order_release); } } // This code used to be responsible for deleting the TLS, but we keep it // forever, since binder threads would often race process destruction. // b/77934844. Keeping a few lines here for visibility of the history. // IPCThreadState is actually stored in threadDestructor. // // void IPCThreadState::shutdown() // { // if (gHaveTLS.load(std::memory_order_acquire)) { // // XXX Need to wait for all thread pool threads to exit! // IPCThreadState* st = (IPCThreadState*)pthread_getspecific(gTLS); // if (st) { // delete st; // pthread_setspecific(gTLS, nullptr); // } // pthread_key_delete(gTLS); // gHaveTLS.store(false, std::memory_order_release); // } // } void IPCThreadState::disableBackgroundScheduling(bool disable) { Loading
libs/binder/include/binder/IPCThreadState.h +0 −2 Original line number Diff line number Diff line Loading @@ -180,8 +180,6 @@ public: [[nodiscard]] status_t addFrozenStateChangeCallback(int32_t handle, BpBinder* proxy); [[nodiscard]] status_t removeFrozenStateChangeCallback(int32_t handle, BpBinder* proxy); LIBBINDER_EXPORTED static void shutdown(); // Call this to disable switching threads to background scheduling when // receiving incoming IPC calls. This is specifically here for the // Android system process, since it expects to have background apps calling Loading