libbinder: use base::GetThreadId instead of gettid
RpcSession uses gettid() to identify the current thread
which is less portable than GetThreadId().
Test: atest binderRpcTest
Bug: 224644083
Change-Id: I0d6020ef41af85c20bb58b89598812f2e790a38b
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index b7ca88a..6c48c88 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 @@
{
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<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 @@
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 @@
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) {