diff options
-rw-r--r-- | libs/binder/RpcSession.cpp | 12 | ||||
-rw-r--r-- | libs/binder/include/binder/RpcSession.h | 5 |
2 files changed, 7 insertions, 10 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index b7ca88afce..6c48c88661 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -43,10 +43,6 @@ #include "RpcWireFormat.h" #include "Utils.h" -#ifdef __GLIBC__ -extern "C" pid_t gettid(); -#endif - #ifndef __ANDROID_RECOVERY__ #include <android_runtime/vm.h> #include <jni.h> @@ -693,7 +689,7 @@ status_t RpcSession::addOutgoingConnection(std::unique_ptr<RpcTransport> rpcTran { std::lock_guard<std::mutex> _l(mMutex); connection->rpcTransport = std::move(rpcTransport); - connection->exclusiveTid = gettid(); + connection->exclusiveTid = base::GetThreadId(); mConnections.mOutgoing.push_back(connection); } @@ -750,7 +746,7 @@ sp<RpcSession::RpcConnection> RpcSession::assignIncomingConnectionToThisThread( sp<RpcConnection> session = sp<RpcConnection>::make(); session->rpcTransport = std::move(rpcTransport); - session->exclusiveTid = gettid(); + session->exclusiveTid = base::GetThreadId(); mConnections.mIncoming.push_back(session); mConnections.mMaxIncoming = mConnections.mIncoming.size(); @@ -786,7 +782,7 @@ status_t RpcSession::ExclusiveConnection::find(const sp<RpcSession>& session, Co connection->mConnection = nullptr; connection->mReentrant = false; - pid_t tid = gettid(); + uint64_t tid = base::GetThreadId(); std::unique_lock<std::mutex> _l(session->mMutex); session->mConnections.mWaitingThreads++; @@ -873,7 +869,7 @@ status_t RpcSession::ExclusiveConnection::find(const sp<RpcSession>& session, Co return OK; } -void RpcSession::ExclusiveConnection::findConnection(pid_t tid, sp<RpcConnection>* exclusive, +void RpcSession::ExclusiveConnection::findConnection(uint64_t tid, sp<RpcConnection>* exclusive, sp<RpcConnection>* available, std::vector<sp<RpcConnection>>& sockets, size_t socketsIndexHint) { diff --git a/libs/binder/include/binder/RpcSession.h b/libs/binder/include/binder/RpcSession.h index a5794428de..cb8158489f 100644 --- a/libs/binder/include/binder/RpcSession.h +++ b/libs/binder/include/binder/RpcSession.h @@ -15,6 +15,7 @@ */ #pragma once +#include <android-base/threads.h> #include <android-base/unique_fd.h> #include <binder/IBinder.h> #include <binder/RpcTransport.h> @@ -211,7 +212,7 @@ private: // whether this or another thread is currently using this fd to make // or receive transactions. - std::optional<pid_t> exclusiveTid; + std::optional<uint64_t> exclusiveTid; bool allowNested = false; }; @@ -276,7 +277,7 @@ private: const sp<RpcConnection>& get() { return mConnection; } private: - static void findConnection(pid_t tid, sp<RpcConnection>* exclusive, + static void findConnection(uint64_t tid, sp<RpcConnection>* exclusive, sp<RpcConnection>* available, std::vector<sp<RpcConnection>>& sockets, size_t socketsIndexHint); |