提交 4f3702c4 编写于 作者: L liangshenglin1 提交者: Gitee

fix bug of fail to get caller pid uid

上级 a496461a
......@@ -848,7 +848,7 @@ template <class T> void DBinderBaseInvoker<T>::ProcessTransaction(dbinder_transa
const pid_t oldPid = GetCallerPid();
const auto oldUid = static_cast<const uid_t>(GetCallerUid());
const std::string oldDeviceId = GetCallerDeviceID();
uint32_t oldStatus = GetStatus();
if (CheckAndSetCallerInfo(listenFd, tr->cookie) != ERR_NONE) {
DBINDER_BASE_LOGE("set user info error, maybe cookie is NOT belong to current caller");
return;
......@@ -898,7 +898,7 @@ template <class T> void DBinderBaseInvoker<T>::ProcessTransaction(dbinder_transa
SetCallerPid(oldPid);
SetCallerUid(oldUid);
SetCallerDeviceID(oldDeviceId);
SetStatus(IRemoteInvoker::IDLE_INVOKER);
SetStatus(oldStatus);
}
template <class T> void DBinderBaseInvoker<T>::ProcessReply(dbinder_transaction_data *tr, uint32_t listenFd)
......
......@@ -423,6 +423,7 @@ void BinderInvoker::OnTransaction(const uint8_t *buffer)
#endif
const pid_t oldPid = callerPid_;
const auto oldUid = static_cast<const uid_t>(callerUid_);
uint32_t oldStatus = status_;
callerPid_ = tr->sender_pid;
callerUid_ = tr->sender_euid;
SetStatus(IRemoteInvoker::ACTIVE_INVOKER);
......@@ -452,7 +453,7 @@ void BinderInvoker::OnTransaction(const uint8_t *buffer)
}
callerPid_ = oldPid;
callerUid_ = oldUid;
SetStatus(IRemoteInvoker::IDLE_INVOKER);
SetStatus(oldStatus);
}
void BinderInvoker::OnAttemptAcquire()
......
......@@ -58,7 +58,6 @@ private:
DISALLOW_COPY_AND_MOVE(DBinderRemoteListener);
std::mutex busManagerMutex_;
std::shared_ptr<ISessionService> softbusManager_;
sptr<DBinderService> dBinderService_;
};
} // namespace OHOS
......
......@@ -35,7 +35,7 @@ DBinderRemoteListener::~DBinderRemoteListener()
bool DBinderRemoteListener::StartListener()
{
std::lock_guard<std::mutex> lockGuard(busManagerMutex_);
softbusManager_ = ISessionService::GetInstance();
std::shared_ptr<ISessionService> softbusManager_ = ISessionService::GetInstance();
if (softbusManager_ == nullptr) {
DBINDER_LOGE("fail to get softbus service");
return false;
......@@ -52,6 +52,7 @@ bool DBinderRemoteListener::StartListener()
bool DBinderRemoteListener::StopListener()
{
std::lock_guard<std::mutex> lockGuard(busManagerMutex_);
std::shared_ptr<ISessionService> softbusManager_ = ISessionService::GetInstance();
if (softbusManager_ == nullptr) {
DBINDER_LOGE("softbus manager is null");
return false;
......@@ -90,6 +91,7 @@ bool DBinderRemoteListener::SendDataToRemote(const std::string &deviceId, const
bool DBinderRemoteListener::CloseDatabusSession(const std::string &deviceId)
{
std::lock_guard<std::mutex> lockGuard(busManagerMutex_);
std::shared_ptr<ISessionService> softbusManager_ = ISessionService::GetInstance();
if (softbusManager_ == nullptr) {
DBINDER_LOGE("softbus manager is null");
return false;
......@@ -108,6 +110,7 @@ bool DBinderRemoteListener::CloseDatabusSession(const std::string &deviceId)
std::shared_ptr<Session> DBinderRemoteListener::OpenSoftbusSession(const std::string &peerDeviceId)
{
std::lock_guard<std::mutex> lockGuard(busManagerMutex_);
std::shared_ptr<ISessionService> softbusManager_ = ISessionService::GetInstance();
if (softbusManager_ == nullptr) {
DBINDER_LOGE("softbus manager is null");
return nullptr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册