!6167 fix:connect lock add

Merge pull request !6167 from 冯叶叶/master
This commit is contained in:
openharmony_ci 2024-05-21 01:27:47 +00:00 committed by Gitee
commit e2afd7358a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 12 additions and 5 deletions

View File

@ -242,11 +242,17 @@ int AuthNegotiateChannel::OpenConnection(const OpenParam &param, const std::shar
};
auto requestId = AuthGenRequestId();
ret = AuthOpenConn(&authConnInfo, requestId, &authConnCallback, isMeta);
CONN_CHECK_AND_RETURN_RET_LOGW(ret == SOFTBUS_OK, SOFTBUS_ERR, CONN_WIFI_DIRECT, "auth open connect failed");
{
std::lock_guard lock(lock_);
requestIdToDeviceIdMap_[requestId] = param.remoteUuid;
}
std::lock_guard lock(lock_);
requestIdToDeviceIdMap_[requestId] = param.remoteUuid;
return SOFTBUS_OK;
ret = AuthOpenConn(&authConnInfo, requestId, &authConnCallback, isMeta);
if (ret != SOFTBUS_OK) {
CONN_LOGE(CONN_WIFI_DIRECT, "auth open connect failed, error=%{public}d", ret);
std::lock_guard lock(lock_);
requestIdToDeviceIdMap_.erase(requestId);
}
return ret;
}
} // namespace OHOS::SoftBus

View File

@ -89,6 +89,7 @@ public:
std::lock_guard lock(executorLock_);
auto it = executors_.find(remoteDeviceId);
if (it == executors_.end()) {
CONN_LOGI(CONN_WIFI_DIRECT, "executor not exist");
return;
}