diff --git a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp index 79855be6b3fb76bca160753b02dd109a09b0ee74..1fd2e3f42d23b6b40858c038dd85fc7ab5ad6a2a 100755 --- a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp +++ b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp @@ -474,6 +474,17 @@ Status SoftBusAdapter::SendData(const PipeInfo &pipeInfo, const DeviceId &device pipeInfo.pipeId.c_str(), info.msgType, sessionId); return Status::CREATE_SESSION_ERROR; } + SetOpenSessionId(sessionId); + int state = WaitSessionOpen(); + { + lock_guard lock(notifyFlagMutex_); + notifyFlag_ = false; + } + ZLOGD("Waited for notification, state:%{public}d", state); + if (state != SOFTBUS_OK) { + ZLOGE("OpenSession callback result error"); + return Status::CREATE_SESSION_ERROR; + } ZLOGD("[SendBytes] start,sessionId is %{public}d, size is %{public}d, session type is %{public}d.", sessionId, size, attr.dataType); int32_t ret = SendBytes(sessionId, (void*)ptr, size); @@ -601,6 +612,10 @@ int AppDataListenerWrap::OnSessionOpened(int sessionId, int result) char mySessionName[SESSION_NAME_SIZE_MAX] = ""; char peerSessionName[SESSION_NAME_SIZE_MAX] = ""; char peerDevId[DEVICE_ID_SIZE_MAX] = ""; + + if (sessionId == softBusAdapter_->GetOpenSessionId()) { + softBusAdapter_->NotifySessionOpen(result); + } if (result != SOFTBUS_OK) { ZLOGW("session %{public}d open failed, result:%{public}d.", sessionId, result); return result;