修改变量命名

Signed-off-by: liqiao49 <liqiao49@huawei.com>
This commit is contained in:
liqiao49
2023-08-01 20:08:05 +08:00
parent ed3334be61
commit 5763db9fe8
2 changed files with 14 additions and 17 deletions
@@ -67,14 +67,14 @@ private:
void Release();
private:
std::atomic<bool> sessionServer_ {false};
std::mutex sessServerMutex_;
std::atomic<bool> isSessSerCreateFlag_ = false;
std::mutex sessSerOperMutex_;
std::mutex operationMutex_;
std::string remoteDeviceId_;
std::map<std::string, int32_t> remoteDevSessionMap_;
std::map<std::string, bool> channelStatusMap_;
std::condition_variable openSessionWaitCond_;
std::string mySessionName_ = "";
std::string localSessionName_ = "";
int32_t sessionId_ = 0;
std::shared_ptr<DInputTransbaseSourceCallback> srcCallback_;
@@ -127,20 +127,18 @@ int32_t DistributedInputTransportBase::Init()
std::string networkId = localNode->networkId;
DHLOGI("Init device local networkId is %s", GetAnonyString(networkId).c_str());
mySessionName_ = SESSION_NAME + networkId.substr(0, INTERCEPT_STRING_LENGTH);
std::unique_lock<std::mutex> sessionServerLock(sessServerMutex_);
if (sessionServer_.load()) {
std::unique_lock<std::mutex> sessionServerLock(sessSerOperMutex_);
if (isSessSerCreateFlag_.load()) {
DHLOGI("SessionServer already create success.");
return DH_SUCCESS;
}
int32_t ret = CreateSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str(), &iSessionListener);
localSessionName_ = SESSION_NAME + networkId.substr(0, INTERCEPT_STRING_LENGTH);
int32_t ret = CreateSessionServer(DINPUT_PKG_NAME.c_str(), localSessionName_.c_str(), &iSessionListener);
if (ret != DH_SUCCESS) {
DHLOGE("Init CreateSessionServer failed, error code %d.", ret);
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_INIT_FAIL;
}
sessionServer_.store(true);
isSessSerCreateFlag_.store(true);
return DH_SUCCESS;
}
@@ -153,15 +151,14 @@ void DistributedInputTransportBase::Release()
}
{
std::unique_lock<std::mutex> sessionServerLock(sessServerMutex_);
if (!sessionServer_.load()) {
std::unique_lock<std::mutex> sessionServerLock(sessSerOperMutex_);
if (!isSessSerCreateFlag_.load()) {
DHLOGI("SessionServer already remove success.");
} else {
(void)RemoveSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str());
sessionServer_.store(false);
(void)RemoveSessionServer(DINPUT_PKG_NAME.c_str(), localSessionName_.c_str());
isSessSerCreateFlag_.store(false);
}
}
remoteDevSessionMap_.clear();
channelStatusMap_.clear();
}
@@ -199,7 +196,7 @@ int32_t DistributedInputTransportBase::StartSession(const std::string &remoteDev
DHLOGI("OpenInputSoftbus peerSessionName:%s", peerSessionName.c_str());
StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_OPEN_SESSION_START, DINPUT_OPEN_SESSION_TASK);
int32_t sessionId = OpenSession(mySessionName_.c_str(), peerSessionName.c_str(), remoteDevId.c_str(),
int32_t sessionId = OpenSession(localSessionName_.c_str(), peerSessionName.c_str(), remoteDevId.c_str(),
GROUP_ID.c_str(), &g_sessionAttr);
if (sessionId < 0) {
DHLOGE("OpenSession fail, remoteDevId: %s, sessionId: %d", GetAnonyString(remoteDevId).c_str(), sessionId);
@@ -207,7 +204,7 @@ int32_t DistributedInputTransportBase::StartSession(const std::string &remoteDev
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_OPEN_SESSION_FAIL;
}
HiDumper::GetInstance().CreateSessionInfo(remoteDevId, sessionId, mySessionName_, peerSessionName,
HiDumper::GetInstance().CreateSessionInfo(remoteDevId, sessionId, localSessionName_, peerSessionName,
SessionStatus::OPENING);
DHLOGI("Wait for channel session opened.");