!3446 TransOnExchangeUdpInfoReply接收对端的关闭响应消息时,解析出错应该关闭对应的通道

Merge pull request !3446 from zhangshen/UdpChannel
This commit is contained in:
openharmony_ci 2023-01-12 09:17:25 +00:00 committed by Gitee
commit 717b67d2ed
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 20 additions and 39 deletions

View File

@ -238,6 +238,7 @@ NO_SANITIZE("cfi") int32_t TransOpenChannel(const SessionParam *param, TransInfo
if (TransLaneMgrAddLane(transInfo->channelId, transInfo->channelType,
&connInfo, laneId, &appInfo->myData) != SOFTBUS_OK) {
TransCloseChannel(transInfo->channelId, transInfo->channelType);
goto EXIT_ERR;
}
@ -250,9 +251,6 @@ EXIT_ERR:
if (laneId != 0) {
LnnFreeLane(laneId);
}
if (transInfo->channelId != INVALID_CHANNEL_ID) {
(void)TransCloseChannel(transInfo->channelId, transInfo->channelType);
}
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "server TransOpenChannel err");
return INVALID_CHANNEL_ID;
}

View File

@ -664,16 +664,21 @@ static int32_t TransProxyOpenNewConnChannel(
NO_SANITIZE("cfi") int32_t TransProxyOpenConnChannel(const AppInfo *appInfo, const ConnectOption *connInfo,
int32_t *channelId)
{
int ret = SOFTBUS_ERR;
ProxyConnInfo conn;
int32_t chanNewId = TransProxyGetNewMyId();
*channelId = chanNewId;
if (TransGetConn(connInfo, &conn) == SOFTBUS_OK) {
return TransProxyConnExistProc(&conn, appInfo, chanNewId);
ret = TransProxyConnExistProc(&conn, appInfo, chanNewId);
} else {
ListenerModule module = PROXY;
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "%s:get listener module %d!", __func__, module);
return TransProxyOpenNewConnChannel(module, appInfo, connInfo, chanNewId);
ret = TransProxyOpenNewConnChannel(module, appInfo, connInfo, chanNewId);
}
if (ret == SOFTBUS_OK) {
*channelId = chanNewId;
}
return ret;
}
static void TransProxyOnDataReceived(uint32_t connectionId, ConnModule moduleId,

View File

@ -308,20 +308,9 @@ NO_SANITIZE("cfi") int32_t NotifyChannelOpenFailed(int32_t channelId, int32_t er
}
if (conn.serverSide == false) {
int32_t uid = 0;
int32_t pid = 0;
char pkgName[PKG_NAME_SIZE_MAX] = {0};
if (TransTdcGetPkgName(conn.appInfo.myData.sessionName, pkgName, PKG_NAME_SIZE_MAX) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get pkg name fail.");
return SOFTBUS_ERR;
}
if (TransTdcGetUidAndPid(conn.appInfo.myData.sessionName, &uid, &pid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get uid and pid fail.");
return SOFTBUS_ERR;
}
int ret = TransTdcOnChannelOpenFailed(pkgName, pid, channelId, errCode);
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO,
"TCP direct channel failed, channelId = %d, ret = %d", channelId, ret);
AppInfoData *myData = &conn.appInfo.myData;
int ret = TransTdcOnChannelOpenFailed(myData->pkgName, myData->pid, channelId, errCode);
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "channelId = %d, ret = %d", channelId, ret);
return ret;
}
return SOFTBUS_OK;

View File

@ -145,26 +145,13 @@ NO_SANITIZE("cfi") int32_t NotifyUdpChannelClosed(const AppInfo *info)
NO_SANITIZE("cfi") int32_t NotifyUdpChannelOpenFailed(const AppInfo *info, int32_t errCode)
{
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "notify udp channel open failed.");
char pkgName[PKG_NAME_SIZE_MAX] = {0};
int32_t ret = g_channelCb->GetPkgNameBySessionName(info->myData.sessionName, pkgName, PKG_NAME_SIZE_MAX);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get pkg name fail.");
return SOFTBUS_ERR;
}
int32_t uid = 0;
int32_t pid = 0;
ret = g_channelCb->GetUidAndPidBySessionName(info->myData.sessionName, &uid, &pid);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get uid and pid err.");
return SOFTBUS_ERR;
}
ret = g_channelCb->OnChannelOpenFailed(pkgName, pid, (int32_t)(info->myData.channelId), CHANNEL_TYPE_UDP, errCode);
int ret = g_channelCb->OnChannelOpenFailed(info->myData.pkgName, info->myData.pid,
(int32_t)(info->myData.channelId), CHANNEL_TYPE_UDP, errCode);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "notify udp channel open failed err.");
return SOFTBUS_ERR;
}
return SOFTBUS_OK;
return ret;
}
NO_SANITIZE("cfi") int32_t NotifyUdpQosEvent(const AppInfo *info, int32_t eventId, int32_t tvCount, const QosTv *tvList)
@ -249,7 +236,6 @@ static int32_t CloseUdpChannel(AppInfo *appInfo)
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "process udp channel close state");
if (TransDelUdpChannel(appInfo->myData.channelId) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "delete udp channel failed.");
return SOFTBUS_ERR;
}
if (NotifyUdpChannelClosed(appInfo) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_WARN, "notify app udp channel closed failed.");
@ -453,7 +439,7 @@ static void TransOnExchangeUdpInfoReply(int64_t authId, int64_t seq, const cJSON
int32_t errCode = SOFTBUS_OK;
if (TransUnpackReplyErrInfo(msg, &errCode) == SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "receive err reply info");
ProcessAbnormalUdpChannelState(&(channel.info), errCode, false);
ProcessAbnormalUdpChannelState(&(channel.info), errCode, true);
return;
}
if (TransUnpackReplyUdpInfo(msg, &(channel.info)) != SOFTBUS_OK) {
@ -574,6 +560,9 @@ static void UdpOnAuthConnOpened(uint32_t requestId, int64_t authId)
SoftBusFree(channel);
goto EXIT_ERR;
}
if (channel->info.udpChannelOptType == TYPE_UDP_CHANNEL_CLOSE) {
(void)TransDelUdpChannel(channel->info.myData.channelId);
}
SoftBusFree(channel);
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "UdpOnAuthConnOpened end");

View File

@ -504,9 +504,9 @@ void CloseSession(int sessionId)
ret = ClientDeleteSession(sessionId);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "CloseSession delete session err: ret=%d", ret);
return;
}
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "CloseSession ok");
return;
}
int GetMySessionName(int sessionId, char *sessionName, unsigned int len)