Loading libs/binder/FdTrigger.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -21,13 +21,15 @@ #include <poll.h> #include <android-base/scopeguard.h> #include <binder/Functional.h> #include "RpcState.h" #include "Utils.h" namespace android { using namespace android::binder::impl; std::unique_ptr<FdTrigger> FdTrigger::make() { auto ret = std::make_unique<FdTrigger>(); #ifndef BINDER_RPC_SINGLE_THREADED Loading Loading @@ -75,8 +77,7 @@ status_t FdTrigger::triggerablePoll(const android::RpcTransportFd& transportFd, "Only one thread should be polling on Fd!"); transportFd.setPollingState(true); auto pollingStateGuard = android::base::make_scope_guard([&]() { transportFd.setPollingState(false); }); auto pollingStateGuard = make_scope_guard([&]() { transportFd.setPollingState(false); }); int ret = TEMP_FAILURE_RETRY(poll(pfd, countof(pfd), -1)); if (ret < 0) { Loading libs/binder/Parcel.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include <binder/Binder.h> #include <binder/BpBinder.h> #include <binder/Functional.h> #include <binder/IPCThreadState.h> #include <binder/Parcel.h> #include <binder/ProcessState.h> Loading @@ -40,7 +41,6 @@ #include <binder/Status.h> #include <binder/TextOutput.h> #include <android-base/scopeguard.h> #ifndef BINDER_DISABLE_BLOB #include <cutils/ashmem.h> #endif Loading Loading @@ -92,6 +92,8 @@ static size_t pad_size(size_t s) { namespace android { using namespace android::binder::impl; // many things compile this into prebuilts on the stack #ifdef __LP64__ static_assert(sizeof(Parcel) == 120); Loading Loading @@ -584,7 +586,7 @@ status_t Parcel::appendFrom(const Parcel* parcel, size_t offset, size_t len) { } const size_t savedDataPos = mDataPos; base::ScopeGuard scopeGuard = [&]() { mDataPos = savedDataPos; }; auto scopeGuard = make_scope_guard([&]() { mDataPos = savedDataPos; }); rpcFields->mObjectPositions.reserve(otherRpcFields->mObjectPositions.size()); if (otherRpcFields->mFds != nullptr) { Loading libs/binder/ProcessState.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ #include <binder/ProcessState.h> #include <android-base/scopeguard.h> #include <android-base/strings.h> #include <binder/BpBinder.h> #include <binder/Functional.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/Stability.h> Loading Loading @@ -60,6 +60,8 @@ const char* kDefaultDriver = "/dev/binder"; namespace android { using namespace android::binder::impl; class PoolThread : public Thread { public: Loading Loading @@ -430,7 +432,7 @@ status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) { size_t ProcessState::getThreadPoolMaxTotalThreadCount() const { pthread_mutex_lock(&mThreadCountLock); base::ScopeGuard detachGuard = [&]() { pthread_mutex_unlock(&mThreadCountLock); }; auto detachGuard = make_scope_guard([&]() { pthread_mutex_unlock(&mThreadCountLock); }); if (mThreadPoolStarted) { LOG_ALWAYS_FATAL_IF(mKernelStartedThreads > mMaxThreads + 1, Loading libs/binder/RecordedTransaction.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -16,12 +16,13 @@ #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/scopeguard.h> #include <android-base/unique_fd.h> #include <binder/Functional.h> #include <binder/RecordedTransaction.h> #include <sys/mman.h> #include <algorithm> using namespace android::binder::impl; using android::Parcel; using android::base::borrowed_fd; using android::base::unique_fd; Loading Loading @@ -218,7 +219,7 @@ std::optional<RecordedTransaction> RecordedTransaction::fromFile(const unique_fd size_t memoryMappedSize = chunkPayloadSize + mmapPayloadStartOffset; void* mappedMemory = mmap(NULL, memoryMappedSize, PROT_READ, MAP_SHARED, fd.get(), mmapPageAlignedStart); auto mmap_guard = android::base::make_scope_guard( auto mmap_guard = make_scope_guard( [mappedMemory, memoryMappedSize] { munmap(mappedMemory, memoryMappedSize); }); transaction_checksum_t* payloadMap = Loading libs/binder/RpcServer.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ #include <thread> #include <vector> #include <android-base/scopeguard.h> #include <binder/Functional.h> #include <binder/Parcel.h> #include <binder/RpcServer.h> #include <binder/RpcTransportRaw.h> Loading @@ -44,7 +44,7 @@ namespace android { constexpr size_t kSessionIdBytes = 32; using base::ScopeGuard; using namespace android::binder::impl; using base::unique_fd; RpcServer::RpcServer(std::unique_ptr<RpcTransportCtx> ctx) : mCtx(std::move(ctx)) {} Loading Loading @@ -454,11 +454,12 @@ void RpcServer::establishConnection( LOG_ALWAYS_FATAL_IF(threadId == server->mConnectingThreads.end(), "Must establish connection on owned thread"); thisThread = std::move(threadId->second); ScopeGuard detachGuard = [&]() { auto detachGuardLambda = [&]() { thisThread.detach(); _l.unlock(); server->mShutdownCv.notify_all(); }; auto detachGuard = make_scope_guard(std::ref(detachGuardLambda)); server->mConnectingThreads.erase(threadId); if (status != OK || server->mShutdownTrigger->isTriggered()) { Loading Loading @@ -544,7 +545,7 @@ void RpcServer::establishConnection( return; } detachGuard.Disable(); detachGuard.release(); session->preJoinThreadOwnership(std::move(thisThread)); } Loading Loading
libs/binder/FdTrigger.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -21,13 +21,15 @@ #include <poll.h> #include <android-base/scopeguard.h> #include <binder/Functional.h> #include "RpcState.h" #include "Utils.h" namespace android { using namespace android::binder::impl; std::unique_ptr<FdTrigger> FdTrigger::make() { auto ret = std::make_unique<FdTrigger>(); #ifndef BINDER_RPC_SINGLE_THREADED Loading Loading @@ -75,8 +77,7 @@ status_t FdTrigger::triggerablePoll(const android::RpcTransportFd& transportFd, "Only one thread should be polling on Fd!"); transportFd.setPollingState(true); auto pollingStateGuard = android::base::make_scope_guard([&]() { transportFd.setPollingState(false); }); auto pollingStateGuard = make_scope_guard([&]() { transportFd.setPollingState(false); }); int ret = TEMP_FAILURE_RETRY(poll(pfd, countof(pfd), -1)); if (ret < 0) { Loading
libs/binder/Parcel.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include <binder/Binder.h> #include <binder/BpBinder.h> #include <binder/Functional.h> #include <binder/IPCThreadState.h> #include <binder/Parcel.h> #include <binder/ProcessState.h> Loading @@ -40,7 +41,6 @@ #include <binder/Status.h> #include <binder/TextOutput.h> #include <android-base/scopeguard.h> #ifndef BINDER_DISABLE_BLOB #include <cutils/ashmem.h> #endif Loading Loading @@ -92,6 +92,8 @@ static size_t pad_size(size_t s) { namespace android { using namespace android::binder::impl; // many things compile this into prebuilts on the stack #ifdef __LP64__ static_assert(sizeof(Parcel) == 120); Loading Loading @@ -584,7 +586,7 @@ status_t Parcel::appendFrom(const Parcel* parcel, size_t offset, size_t len) { } const size_t savedDataPos = mDataPos; base::ScopeGuard scopeGuard = [&]() { mDataPos = savedDataPos; }; auto scopeGuard = make_scope_guard([&]() { mDataPos = savedDataPos; }); rpcFields->mObjectPositions.reserve(otherRpcFields->mObjectPositions.size()); if (otherRpcFields->mFds != nullptr) { Loading
libs/binder/ProcessState.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ #include <binder/ProcessState.h> #include <android-base/scopeguard.h> #include <android-base/strings.h> #include <binder/BpBinder.h> #include <binder/Functional.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/Stability.h> Loading Loading @@ -60,6 +60,8 @@ const char* kDefaultDriver = "/dev/binder"; namespace android { using namespace android::binder::impl; class PoolThread : public Thread { public: Loading Loading @@ -430,7 +432,7 @@ status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) { size_t ProcessState::getThreadPoolMaxTotalThreadCount() const { pthread_mutex_lock(&mThreadCountLock); base::ScopeGuard detachGuard = [&]() { pthread_mutex_unlock(&mThreadCountLock); }; auto detachGuard = make_scope_guard([&]() { pthread_mutex_unlock(&mThreadCountLock); }); if (mThreadPoolStarted) { LOG_ALWAYS_FATAL_IF(mKernelStartedThreads > mMaxThreads + 1, Loading
libs/binder/RecordedTransaction.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -16,12 +16,13 @@ #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/scopeguard.h> #include <android-base/unique_fd.h> #include <binder/Functional.h> #include <binder/RecordedTransaction.h> #include <sys/mman.h> #include <algorithm> using namespace android::binder::impl; using android::Parcel; using android::base::borrowed_fd; using android::base::unique_fd; Loading Loading @@ -218,7 +219,7 @@ std::optional<RecordedTransaction> RecordedTransaction::fromFile(const unique_fd size_t memoryMappedSize = chunkPayloadSize + mmapPayloadStartOffset; void* mappedMemory = mmap(NULL, memoryMappedSize, PROT_READ, MAP_SHARED, fd.get(), mmapPageAlignedStart); auto mmap_guard = android::base::make_scope_guard( auto mmap_guard = make_scope_guard( [mappedMemory, memoryMappedSize] { munmap(mappedMemory, memoryMappedSize); }); transaction_checksum_t* payloadMap = Loading
libs/binder/RpcServer.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ #include <thread> #include <vector> #include <android-base/scopeguard.h> #include <binder/Functional.h> #include <binder/Parcel.h> #include <binder/RpcServer.h> #include <binder/RpcTransportRaw.h> Loading @@ -44,7 +44,7 @@ namespace android { constexpr size_t kSessionIdBytes = 32; using base::ScopeGuard; using namespace android::binder::impl; using base::unique_fd; RpcServer::RpcServer(std::unique_ptr<RpcTransportCtx> ctx) : mCtx(std::move(ctx)) {} Loading Loading @@ -454,11 +454,12 @@ void RpcServer::establishConnection( LOG_ALWAYS_FATAL_IF(threadId == server->mConnectingThreads.end(), "Must establish connection on owned thread"); thisThread = std::move(threadId->second); ScopeGuard detachGuard = [&]() { auto detachGuardLambda = [&]() { thisThread.detach(); _l.unlock(); server->mShutdownCv.notify_all(); }; auto detachGuard = make_scope_guard(std::ref(detachGuardLambda)); server->mConnectingThreads.erase(threadId); if (status != OK || server->mShutdownTrigger->isTriggered()) { Loading Loading @@ -544,7 +545,7 @@ void RpcServer::establishConnection( return; } detachGuard.Disable(); detachGuard.release(); session->preJoinThreadOwnership(std::move(thisThread)); } Loading