Loading libs/binder/RpcState.cpp +13 −15 Original line number Diff line number Diff line Loading @@ -244,33 +244,31 @@ void RpcState::clear() { "New state should be impossible after terminating!"); return; } mTerminated = true; if (SHOULD_LOG_RPC_DETAIL) { ALOGE("RpcState::clear()"); dumpLocked(); } // if the destructor of a binder object makes another RPC call, then calling // decStrong could deadlock. So, we must hold onto these binders until // mNodeMutex is no longer taken. std::vector<sp<IBinder>> tempHoldBinder; mTerminated = true; // invariants for (auto& [address, node] : mNodeForAddress) { sp<IBinder> binder = node.binder.promote(); LOG_ALWAYS_FATAL_IF(binder == nullptr, bool guaranteedHaveBinder = node.timesSent > 0; if (guaranteedHaveBinder) { LOG_ALWAYS_FATAL_IF(node.sentRef == nullptr, "Binder expected to be owned with address: %" PRIu64 " %s", address, node.toString().c_str()); if (node.sentRef != nullptr) { tempHoldBinder.push_back(node.sentRef); } } mNodeForAddress.clear(); // if the destructor of a binder object makes another RPC call, then calling // decStrong could deadlock. So, we must hold onto these binders until // mNodeMutex is no longer taken. auto temp = std::move(mNodeForAddress); mNodeForAddress.clear(); // RpcState isn't reusable, but for future/explicit _l.unlock(); tempHoldBinder.clear(); // explicit temp.clear(); // explicit } void RpcState::dumpLocked() { Loading libs/binder/tests/binderRpcTest.cpp +0 −7 Original line number Diff line number Diff line Loading @@ -1029,13 +1029,6 @@ TEST_P(BinderRpc, Callbacks) { // since this session has an incoming connection w/ a threadpool, we // need to manually shut it down EXPECT_TRUE(proc.proc.sessions.at(0).session->shutdownAndWait(true)); proc.proc.host.setCustomExitStatusCheck([](int wstatus) { // Flaky. Sometimes gets SIGABRT. EXPECT_TRUE((WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0) || (WIFSIGNALED(wstatus) && WTERMSIG(wstatus) == SIGABRT)) << "server process failed: " << WaitStatusToString(wstatus); }); proc.expectAlreadyShutdown = true; } } Loading Loading
libs/binder/RpcState.cpp +13 −15 Original line number Diff line number Diff line Loading @@ -244,33 +244,31 @@ void RpcState::clear() { "New state should be impossible after terminating!"); return; } mTerminated = true; if (SHOULD_LOG_RPC_DETAIL) { ALOGE("RpcState::clear()"); dumpLocked(); } // if the destructor of a binder object makes another RPC call, then calling // decStrong could deadlock. So, we must hold onto these binders until // mNodeMutex is no longer taken. std::vector<sp<IBinder>> tempHoldBinder; mTerminated = true; // invariants for (auto& [address, node] : mNodeForAddress) { sp<IBinder> binder = node.binder.promote(); LOG_ALWAYS_FATAL_IF(binder == nullptr, bool guaranteedHaveBinder = node.timesSent > 0; if (guaranteedHaveBinder) { LOG_ALWAYS_FATAL_IF(node.sentRef == nullptr, "Binder expected to be owned with address: %" PRIu64 " %s", address, node.toString().c_str()); if (node.sentRef != nullptr) { tempHoldBinder.push_back(node.sentRef); } } mNodeForAddress.clear(); // if the destructor of a binder object makes another RPC call, then calling // decStrong could deadlock. So, we must hold onto these binders until // mNodeMutex is no longer taken. auto temp = std::move(mNodeForAddress); mNodeForAddress.clear(); // RpcState isn't reusable, but for future/explicit _l.unlock(); tempHoldBinder.clear(); // explicit temp.clear(); // explicit } void RpcState::dumpLocked() { Loading
libs/binder/tests/binderRpcTest.cpp +0 −7 Original line number Diff line number Diff line Loading @@ -1029,13 +1029,6 @@ TEST_P(BinderRpc, Callbacks) { // since this session has an incoming connection w/ a threadpool, we // need to manually shut it down EXPECT_TRUE(proc.proc.sessions.at(0).session->shutdownAndWait(true)); proc.proc.host.setCustomExitStatusCheck([](int wstatus) { // Flaky. Sometimes gets SIGABRT. EXPECT_TRUE((WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0) || (WIFSIGNALED(wstatus) && WTERMSIG(wstatus) == SIGABRT)) << "server process failed: " << WaitStatusToString(wstatus); }); proc.expectAlreadyShutdown = true; } } Loading