summaryrefslogtreecommitdiff
path: root/libs/binder/RpcSession.cpp
diff options
context:
space:
mode:
author Andrei Homescu <ahomescu@google.com> 2022-04-23 03:41:09 +0000
committer Andrei Homescu <ahomescu@google.com> 2022-05-17 23:11:55 +0000
commite922b232b5ec6fc7764cd80cb51d43f75f2e20c1 (patch)
tree4f3cd58b2090b76563393b1a81af8ed5fa35d14e /libs/binder/RpcSession.cpp
parentc24c8791e0467a74d75e819f19374036d1233943 (diff)
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
Diffstat (limited to 'libs/binder/RpcSession.cpp')
-rw-r--r--libs/binder/RpcSession.cpp12
1 files changed, 4 insertions, 8 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) {