Loading libs/binder/BpBinder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -510,7 +510,7 @@ void BpBinder::onLastStrongRef(const void* /*id*/) { ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, binderHandle()); if (CC_UNLIKELY(isRpcBinder())) { (void)rpcSession()->sendDecStrong(rpcAddress()); (void)rpcSession()->sendDecStrong(this); return; } IF_ALOGV() { Loading libs/binder/Parcel.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { return INVALID_OPERATION; } } const int32_t handle = proxy ? proxy->getPrivateAccessorForId().binderHandle() : 0; const int32_t handle = proxy ? proxy->getPrivateAccessor().binderHandle() : 0; obj.hdr.type = BINDER_TYPE_HANDLE; obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */ obj.handle = handle; Loading Loading @@ -572,7 +572,7 @@ void Parcel::markForBinder(const sp<IBinder>& binder) { LOG_ALWAYS_FATAL_IF(mData != nullptr, "format must be set before data is written"); if (binder && binder->remoteBinder() && binder->remoteBinder()->isRpcBinder()) { markForRpc(binder->remoteBinder()->getPrivateAccessorForId().rpcSession()); markForRpc(binder->remoteBinder()->getPrivateAccessor().rpcSession()); } } Loading libs/binder/ProcessState.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ ssize_t ProcessState::getStrongRefCountForNode(const sp<BpBinder>& binder) { binder_node_info_for_ref info; memset(&info, 0, sizeof(binder_node_info_for_ref)); info.handle = binder->getPrivateAccessorForId().binderHandle(); info.handle = binder->getPrivateAccessor().binderHandle(); status_t result = ioctl(mDriverFD, BINDER_GET_NODE_INFO_FOR_REF, &info); Loading Loading @@ -301,7 +301,7 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) return nullptr; } sp<BpBinder> b = BpBinder::create(handle); sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle); e->binder = b.get(); if (b) e->refs = b->getWeakRefs(); result = b; Loading libs/binder/RpcSession.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <android-base/hex.h> #include <android-base/macros.h> #include <android_runtime/vm.h> #include <binder/BpBinder.h> #include <binder/Parcel.h> #include <binder/RpcServer.h> #include <binder/RpcTransportRaw.h> Loading Loading @@ -191,7 +192,7 @@ bool RpcSession::shutdownAndWait(bool wait) { if (wait) { LOG_ALWAYS_FATAL_IF(mShutdownListener == nullptr, "Shutdown listener not installed"); mShutdownListener->waitForShutdown(_l); mShutdownListener->waitForShutdown(_l, sp<RpcSession>::fromExisting(this)); LOG_ALWAYS_FATAL_IF(!mThreads.empty(), "Shutdown failed"); } Loading @@ -215,6 +216,10 @@ status_t RpcSession::transact(const sp<IBinder>& binder, uint32_t code, const Pa sp<RpcSession>::fromExisting(this), reply, flags); } status_t RpcSession::sendDecStrong(const BpBinder* binder) { return sendDecStrong(binder->getPrivateAccessor().rpcAddress()); } status_t RpcSession::sendDecStrong(uint64_t address) { ExclusiveConnection connection; status_t status = ExclusiveConnection::find(sp<RpcSession>::fromExisting(this), Loading Loading @@ -245,17 +250,19 @@ status_t RpcSession::readId() { void RpcSession::WaitForShutdownListener::onSessionAllIncomingThreadsEnded( const sp<RpcSession>& session) { (void)session; mShutdown = true; } void RpcSession::WaitForShutdownListener::onSessionIncomingThreadEnded() { mCv.notify_all(); } void RpcSession::WaitForShutdownListener::waitForShutdown(std::unique_lock<std::mutex>& lock) { while (!mShutdown) { void RpcSession::WaitForShutdownListener::waitForShutdown(std::unique_lock<std::mutex>& lock, const sp<RpcSession>& session) { while (session->mIncomingConnections.size() > 0) { if (std::cv_status::timeout == mCv.wait_for(lock, std::chrono::seconds(1))) { ALOGE("Waiting for RpcSession to shut down (1s w/o progress)."); ALOGE("Waiting for RpcSession to shut down (1s w/o progress): %zu incoming connections " "still.", session->mIncomingConnections.size()); } } } Loading libs/binder/RpcState.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind bool isRemote = binder->remoteBinder(); bool isRpc = isRemote && binder->remoteBinder()->isRpcBinder(); if (isRpc && binder->remoteBinder()->getPrivateAccessorForId().rpcSession() != session) { if (isRpc && binder->remoteBinder()->getPrivateAccessor().rpcSession() != session) { // We need to be able to send instructions over the socket for how to // connect to a different server, and we also need to let the host // process know that this is happening. Loading Loading @@ -85,8 +85,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind if (binder == node.binder) { if (isRpc) { // check integrity of data structure uint64_t actualAddr = binder->remoteBinder()->getPrivateAccessorForId().rpcAddress(); uint64_t actualAddr = binder->remoteBinder()->getPrivateAccessor().rpcAddress(); LOG_ALWAYS_FATAL_IF(addr != actualAddr, "Address mismatch %" PRIu64 " vs %" PRIu64, addr, actualAddr); } Loading Loading @@ -185,7 +184,7 @@ status_t RpcState::onBinderEntering(const sp<RpcSession>& session, uint64_t addr // Currently, all binders are assumed to be part of the same session (no // device global binders in the RPC world). it->second.binder = *out = BpBinder::create(session, it->first); it->second.binder = *out = BpBinder::PrivateAccessor::create(session, it->first); it->second.timesRecd = 1; return OK; } Loading Loading
libs/binder/BpBinder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -510,7 +510,7 @@ void BpBinder::onLastStrongRef(const void* /*id*/) { ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, binderHandle()); if (CC_UNLIKELY(isRpcBinder())) { (void)rpcSession()->sendDecStrong(rpcAddress()); (void)rpcSession()->sendDecStrong(this); return; } IF_ALOGV() { Loading
libs/binder/Parcel.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { return INVALID_OPERATION; } } const int32_t handle = proxy ? proxy->getPrivateAccessorForId().binderHandle() : 0; const int32_t handle = proxy ? proxy->getPrivateAccessor().binderHandle() : 0; obj.hdr.type = BINDER_TYPE_HANDLE; obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */ obj.handle = handle; Loading Loading @@ -572,7 +572,7 @@ void Parcel::markForBinder(const sp<IBinder>& binder) { LOG_ALWAYS_FATAL_IF(mData != nullptr, "format must be set before data is written"); if (binder && binder->remoteBinder() && binder->remoteBinder()->isRpcBinder()) { markForRpc(binder->remoteBinder()->getPrivateAccessorForId().rpcSession()); markForRpc(binder->remoteBinder()->getPrivateAccessor().rpcSession()); } } Loading
libs/binder/ProcessState.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ ssize_t ProcessState::getStrongRefCountForNode(const sp<BpBinder>& binder) { binder_node_info_for_ref info; memset(&info, 0, sizeof(binder_node_info_for_ref)); info.handle = binder->getPrivateAccessorForId().binderHandle(); info.handle = binder->getPrivateAccessor().binderHandle(); status_t result = ioctl(mDriverFD, BINDER_GET_NODE_INFO_FOR_REF, &info); Loading Loading @@ -301,7 +301,7 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) return nullptr; } sp<BpBinder> b = BpBinder::create(handle); sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle); e->binder = b.get(); if (b) e->refs = b->getWeakRefs(); result = b; Loading
libs/binder/RpcSession.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <android-base/hex.h> #include <android-base/macros.h> #include <android_runtime/vm.h> #include <binder/BpBinder.h> #include <binder/Parcel.h> #include <binder/RpcServer.h> #include <binder/RpcTransportRaw.h> Loading Loading @@ -191,7 +192,7 @@ bool RpcSession::shutdownAndWait(bool wait) { if (wait) { LOG_ALWAYS_FATAL_IF(mShutdownListener == nullptr, "Shutdown listener not installed"); mShutdownListener->waitForShutdown(_l); mShutdownListener->waitForShutdown(_l, sp<RpcSession>::fromExisting(this)); LOG_ALWAYS_FATAL_IF(!mThreads.empty(), "Shutdown failed"); } Loading @@ -215,6 +216,10 @@ status_t RpcSession::transact(const sp<IBinder>& binder, uint32_t code, const Pa sp<RpcSession>::fromExisting(this), reply, flags); } status_t RpcSession::sendDecStrong(const BpBinder* binder) { return sendDecStrong(binder->getPrivateAccessor().rpcAddress()); } status_t RpcSession::sendDecStrong(uint64_t address) { ExclusiveConnection connection; status_t status = ExclusiveConnection::find(sp<RpcSession>::fromExisting(this), Loading Loading @@ -245,17 +250,19 @@ status_t RpcSession::readId() { void RpcSession::WaitForShutdownListener::onSessionAllIncomingThreadsEnded( const sp<RpcSession>& session) { (void)session; mShutdown = true; } void RpcSession::WaitForShutdownListener::onSessionIncomingThreadEnded() { mCv.notify_all(); } void RpcSession::WaitForShutdownListener::waitForShutdown(std::unique_lock<std::mutex>& lock) { while (!mShutdown) { void RpcSession::WaitForShutdownListener::waitForShutdown(std::unique_lock<std::mutex>& lock, const sp<RpcSession>& session) { while (session->mIncomingConnections.size() > 0) { if (std::cv_status::timeout == mCv.wait_for(lock, std::chrono::seconds(1))) { ALOGE("Waiting for RpcSession to shut down (1s w/o progress)."); ALOGE("Waiting for RpcSession to shut down (1s w/o progress): %zu incoming connections " "still.", session->mIncomingConnections.size()); } } } Loading
libs/binder/RpcState.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind bool isRemote = binder->remoteBinder(); bool isRpc = isRemote && binder->remoteBinder()->isRpcBinder(); if (isRpc && binder->remoteBinder()->getPrivateAccessorForId().rpcSession() != session) { if (isRpc && binder->remoteBinder()->getPrivateAccessor().rpcSession() != session) { // We need to be able to send instructions over the socket for how to // connect to a different server, and we also need to let the host // process know that this is happening. Loading Loading @@ -85,8 +85,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind if (binder == node.binder) { if (isRpc) { // check integrity of data structure uint64_t actualAddr = binder->remoteBinder()->getPrivateAccessorForId().rpcAddress(); uint64_t actualAddr = binder->remoteBinder()->getPrivateAccessor().rpcAddress(); LOG_ALWAYS_FATAL_IF(addr != actualAddr, "Address mismatch %" PRIu64 " vs %" PRIu64, addr, actualAddr); } Loading Loading @@ -185,7 +184,7 @@ status_t RpcState::onBinderEntering(const sp<RpcSession>& session, uint64_t addr // Currently, all binders are assumed to be part of the same session (no // device global binders in the RPC world). it->second.binder = *out = BpBinder::create(session, it->first); it->second.binder = *out = BpBinder::PrivateAccessor::create(session, it->first); it->second.timesRecd = 1; return OK; } Loading