mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-12-19 15:56:47 +00:00
commit
7fd31173c7
@ -65,7 +65,7 @@
|
||||
#define QUERY_RULES_MAX_NUM 10
|
||||
#define MAX_LENGTH_OF_EVENT_DOMAIN 17
|
||||
#define MAX_LENGTH_OF_EVENT_NAME 33
|
||||
#define MAX_LENGTH_OF_SUCCESS_RATE 50
|
||||
#define MAX_LENGTH_OF_SUCCESS_RATE 100
|
||||
|
||||
typedef void (*HandleMessageFunc)(SoftBusMessage* msg);
|
||||
|
||||
@ -103,8 +103,19 @@ typedef struct {
|
||||
typedef struct {
|
||||
int32_t total;
|
||||
int32_t successTotal;
|
||||
int32_t delayNum;
|
||||
int64_t delay;
|
||||
} TransStatsSuccessRateDetail;
|
||||
|
||||
typedef struct {
|
||||
int32_t scene;
|
||||
int32_t stage;
|
||||
int32_t stageRes;
|
||||
char *socketName;
|
||||
int32_t linkType;
|
||||
int32_t delay;
|
||||
} TransStatsPara;
|
||||
|
||||
typedef struct {
|
||||
int32_t openSessionFailTotal;
|
||||
int32_t openSessionSuccessTotal;
|
||||
@ -323,7 +334,17 @@ static void OnCompleteLnn(int32_t reason, int32_t total)
|
||||
g_isLnnQueryEnd = true;
|
||||
}
|
||||
|
||||
static void TransStatsSuccessDetail(bool success, const char *socketName, int32_t linkTypePara)
|
||||
static void UpdateTransSuccessDetail(TransStatsSuccessRateDetail *res, int32_t delay)
|
||||
{
|
||||
res->successTotal++;
|
||||
if (delay < SOFTBUS_ZERO || delay > MINUTE_TIME) {
|
||||
return;
|
||||
}
|
||||
res->delayNum++;
|
||||
res->delay += delay;
|
||||
}
|
||||
|
||||
static void TransStatsSuccessDetail(bool success, const char *socketName, int32_t linkTypePara, int32_t delay)
|
||||
{
|
||||
int linkType = linkTypePara;
|
||||
if (linkType < CONNECT_TCP || linkType >= CONNECT_TYPE_MAX) {
|
||||
@ -346,8 +367,10 @@ static void TransStatsSuccessDetail(bool success, const char *socketName, int32_
|
||||
TransStatsSuccessRateDetail newResult;
|
||||
newResult.successTotal = 0;
|
||||
newResult.total = 1;
|
||||
newResult.delay = 0;
|
||||
newResult.delayNum = 0;
|
||||
if (success) {
|
||||
newResult.successTotal = 1;
|
||||
UpdateTransSuccessDetail(&newResult, delay);
|
||||
}
|
||||
if (LnnMapSet(&g_transStatsInfo.sessionNameLinkTypeMap, keyStr, (const void *)&newResult,
|
||||
sizeof(TransStatsSuccessRateDetail)) != SOFTBUS_OK) {
|
||||
@ -358,16 +381,22 @@ static void TransStatsSuccessDetail(bool success, const char *socketName, int32_
|
||||
}
|
||||
data->total++;
|
||||
if (success) {
|
||||
data->successTotal++;
|
||||
UpdateTransSuccessDetail(data, delay);
|
||||
}
|
||||
TransMapUnlock();
|
||||
}
|
||||
|
||||
static void TransStats(int32_t scene, int32_t stage, int32_t stageRes, const char *socketName, int32_t linkType)
|
||||
static void TransStats(TransStatsPara *transStatsPara)
|
||||
{
|
||||
int32_t scene = transStatsPara->scene;
|
||||
int32_t stage = transStatsPara->stage;
|
||||
int32_t stageRes = transStatsPara->stageRes;
|
||||
const char *socketName = transStatsPara->socketName;
|
||||
int32_t linkType = transStatsPara->linkType;
|
||||
int32_t delay = transStatsPara->delay;
|
||||
if (scene == EVENT_SCENE_OPEN_CHANNEL && stage == EVENT_STAGE_OPEN_CHANNEL_END
|
||||
&& stageRes == EVENT_STAGE_RESULT_OK) {
|
||||
TransStatsSuccessDetail(true, socketName, linkType);
|
||||
TransStatsSuccessDetail(true, socketName, linkType, delay);
|
||||
g_transStatsInfo.openSessionSuccessTotal++;
|
||||
g_transStatsInfo.currentParaSessionNum++;
|
||||
return;
|
||||
@ -375,7 +404,7 @@ static void TransStats(int32_t scene, int32_t stage, int32_t stageRes, const cha
|
||||
|
||||
if (scene == EVENT_SCENE_OPEN_CHANNEL && stage == EVENT_STAGE_OPEN_CHANNEL_END
|
||||
&& stageRes == EVENT_STAGE_RESULT_FAILED) {
|
||||
TransStatsSuccessDetail(false, socketName, linkType);
|
||||
TransStatsSuccessDetail(false, socketName, linkType, delay);
|
||||
g_transStatsInfo.openSessionFailTotal++;
|
||||
return;
|
||||
}
|
||||
@ -417,9 +446,22 @@ static void OnQueryTrans(HiSysEventRecordC srcRecord[], size_t size)
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t timeConsuming = GetInt32ValueByRecord(&srcRecord[i], TIME_CONSUMING_NAME);
|
||||
if (timeConsuming != SOFTBUS_ERR && stageRes == EVENT_STAGE_RESULT_OK && scene == EVENT_SCENE_OPEN_CHANNEL) {
|
||||
g_transStatsInfo.delayTimeTotal += timeConsuming;
|
||||
g_transStatsInfo.delayNum++;
|
||||
}
|
||||
char* socketName = GetStringValueByRecord(&srcRecord[i], SOCKET_KEY_NAME);
|
||||
int32_t linkType = GetInt32ValueByRecord(&srcRecord[i], LINK_TYPE_NAME);
|
||||
TransStats(scene, stage, stageRes, socketName, linkType);
|
||||
TransStatsPara transStatsPara = {
|
||||
.scene = scene,
|
||||
.stage = stage,
|
||||
.stageRes = stageRes,
|
||||
.socketName = socketName,
|
||||
.linkType = linkType,
|
||||
.delay = timeConsuming
|
||||
};
|
||||
TransStats(&transStatsPara);
|
||||
cJSON_free(socketName);
|
||||
if (scene == EVENT_SCENE_CLOSE_CHANNEL_ACTIVE && stage == EVENT_STAGE_CLOSE_CHANNEL &&
|
||||
stageRes == EVENT_STAGE_RESULT_OK && g_transStatsInfo.currentParaSessionNum > 0) {
|
||||
@ -429,11 +471,6 @@ static void OnQueryTrans(HiSysEventRecordC srcRecord[], size_t size)
|
||||
g_transStatsInfo.maxParaSessionNum = (maxParaSessionNum > g_transStatsInfo.currentParaSessionNum) ?
|
||||
maxParaSessionNum : g_transStatsInfo.currentParaSessionNum;
|
||||
|
||||
int32_t timeConsuming = GetInt32ValueByRecord(&srcRecord[i], TIME_CONSUMING_NAME);
|
||||
if (timeConsuming != SOFTBUS_ERR && stageRes == EVENT_STAGE_RESULT_OK) {
|
||||
g_transStatsInfo.delayTimeTotal += timeConsuming;
|
||||
g_transStatsInfo.delayNum++;
|
||||
}
|
||||
int32_t btFlow = GetInt32ValueByRecord(&srcRecord[i], BT_FLOW_NAME);
|
||||
if (btFlow != SOFTBUS_ERR) {
|
||||
g_transStatsInfo.btFlowTotal += btFlow;
|
||||
@ -540,8 +577,8 @@ void GenerateTransSuccessRateString(MapIterator *it, char *res, uint64_t maxLen)
|
||||
if (quantity->total > 0) {
|
||||
rate = 1.0 * quantity->successTotal / quantity->total * RATE_HUNDRED;
|
||||
}
|
||||
int32_t ret = sprintf_s(res, maxLen, "%s,%d,%d,%d,%2.2f", sessionName, linkType, quantity->total,
|
||||
quantity->successTotal, rate);
|
||||
int32_t ret = sprintf_s(res, maxLen, "%s,%d,%d,%d,%2.2f,%d,%lld", sessionName, linkType, quantity->total,
|
||||
quantity->successTotal, rate, quantity->delayNum, quantity->delay);
|
||||
if (ret <= 0) {
|
||||
COMM_LOGE(COMM_DFX, "sprintf_s fail");
|
||||
return;
|
||||
|
@ -33,6 +33,7 @@ typedef enum {
|
||||
EVENT_SCENE_LANE_SCORE = 6,
|
||||
EVENT_SCENE_ACTIVATION = 7,
|
||||
EVENT_SCENE_DETECTION = 8,
|
||||
EVENT_SCENE_OPEN_CHANNEL_SERVER = 9,
|
||||
} TransEventScene;
|
||||
|
||||
typedef enum {
|
||||
|
@ -162,6 +162,7 @@ typedef struct {
|
||||
char *reqId;
|
||||
int64_t timeStart;
|
||||
int32_t linkType;
|
||||
int32_t connectType;
|
||||
bool isFastData;
|
||||
uint32_t dataConfig;
|
||||
} ChannelInfo;
|
||||
|
@ -80,6 +80,15 @@ static void DfxRecordTcpConnectFail(uint32_t pId, ConnectOption *option, TcpConn
|
||||
|
||||
CONN_LOGI(CONN_COMMON, "record tcp conn fail, connectTraceId=%u, reason=%d", statistics->connectTraceId, reason);
|
||||
uint64_t costTime = SoftBusGetSysTimeMs() - statistics->startTime;
|
||||
ConnEventExtra extra = {
|
||||
.linkType = CONNECT_TCP,
|
||||
.errcode = reason,
|
||||
.result = EVENT_STAGE_RESULT_FAILED
|
||||
};
|
||||
if (tcpInfo != NULL) {
|
||||
extra.requestId = (int32_t)tcpInfo->requestId;
|
||||
}
|
||||
CONN_EVENT(EVENT_SCENE_CONNECT, EVENT_STAGE_CONNECT_END, extra);
|
||||
SoftbusRecordConnResult(pId, SOFTBUS_HISYSEVT_CONN_TYPE_TCP, SOFTBUS_EVT_CONN_FAIL, costTime, reason);
|
||||
}
|
||||
|
||||
@ -92,6 +101,15 @@ static void DfxRecordTcpConnectSuccess(uint32_t pId, TcpConnInfoNode *tcpInfo, C
|
||||
|
||||
CONN_LOGI(CONN_COMMON, "record tcp conn success, connectTraceId=%u", statistics->connectTraceId);
|
||||
uint64_t costTime = SoftBusGetSysTimeMs() - statistics->startTime;
|
||||
ConnEventExtra extra = {
|
||||
.linkType = CONNECT_TCP,
|
||||
.costTime = (int32_t)costTime,
|
||||
.result = EVENT_STAGE_RESULT_OK
|
||||
};
|
||||
if (tcpInfo != NULL) {
|
||||
extra.requestId = (int32_t)tcpInfo->requestId;
|
||||
}
|
||||
CONN_EVENT(EVENT_SCENE_CONNECT, EVENT_STAGE_CONNECT_END, extra);
|
||||
SoftbusRecordConnResult(pId, SOFTBUS_HISYSEVT_CONN_TYPE_TCP, SOFTBUS_EVT_CONN_SUCC, costTime,
|
||||
SOFTBUS_HISYSEVT_CONN_OK);
|
||||
}
|
||||
|
@ -110,6 +110,7 @@ typedef struct {
|
||||
int32_t transFlag;
|
||||
int64_t authSeq;
|
||||
int32_t linkType;
|
||||
int32_t connectType;
|
||||
int32_t channelType;
|
||||
int32_t errorCode;
|
||||
int64_t timeStart;
|
||||
|
@ -26,9 +26,11 @@
|
||||
#include "softbus_def.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_feature_config.h"
|
||||
#include "softbus_hisysevt_transreporter.h"
|
||||
#include "softbus_utils.h"
|
||||
#include "trans_auth_message.h"
|
||||
#include "trans_channel_limit.h"
|
||||
#include "trans_event.h"
|
||||
#include "trans_session_manager.h"
|
||||
#include "trans_channel_manager.h"
|
||||
#include "trans_log.h"
|
||||
@ -153,6 +155,8 @@ static int32_t NotifyOpenAuthChannelSuccess(const AppInfo *appInfo, bool isServe
|
||||
channelInfo.autoCloseTime = appInfo->autoCloseTime;
|
||||
channelInfo.reqId = (char*)appInfo->reqId;
|
||||
channelInfo.dataConfig = appInfo->myData.dataConfig;
|
||||
channelInfo.timeStart = appInfo->timeStart;
|
||||
channelInfo.connectType = appInfo->connectType;
|
||||
return g_cb->OnChannelOpened(appInfo->myData.pkgName, appInfo->myData.pid,
|
||||
appInfo->myData.sessionName, &channelInfo);
|
||||
}
|
||||
@ -314,6 +318,14 @@ static void OnRecvAuthChannelRequest(int32_t authId, const char *data, int32_t l
|
||||
return;
|
||||
}
|
||||
|
||||
TransEventExtra extra = {
|
||||
.peerNetworkId = NULL,
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.socketName = NULL,
|
||||
.channelType = CHANNEL_TYPE_AUTH,
|
||||
.authId = authId
|
||||
};
|
||||
AppInfo appInfo;
|
||||
int32_t ret = TransAuthChannelMsgUnpack(data, &appInfo, len);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
@ -321,6 +333,8 @@ static void OnRecvAuthChannelRequest(int32_t authId, const char *data, int32_t l
|
||||
TransPostAuthChannelErrMsg(authId, ret, "unpackRequest");
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
extra.socketName = appInfo.myData.sessionName;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_START, extra);
|
||||
if (!CheckSessionNameValidOnAuthChannel(appInfo.myData.sessionName)) {
|
||||
TRANS_LOGE(TRANS_SVC, "check auth channel pkginfo invalid.");
|
||||
TransPostAuthChannelErrMsg(authId, ret, "check msginfo failed");
|
||||
@ -342,6 +356,9 @@ static void OnRecvAuthChannelRequest(int32_t authId, const char *data, int32_t l
|
||||
TransPostAuthChannelErrMsg(authId, ret, "unpackRequest");
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
extra.channelId = appInfo.myData.channelId;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_START, extra);
|
||||
ret = NotifyOpenAuthChannelSuccess(&appInfo, true);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SVC, "NotifyOpenAuthChannelSuccess failed");
|
||||
@ -354,8 +371,14 @@ static void OnRecvAuthChannelRequest(int32_t authId, const char *data, int32_t l
|
||||
TransPostAuthChannelErrMsg(authId, ret, "send reply failed");
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
return;
|
||||
EXIT_ERR:
|
||||
if (extra.socketName != NULL) {
|
||||
extra.result = EVENT_STAGE_RESULT_FAILED;
|
||||
extra.errcode = ret;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
}
|
||||
DelAuthChannelInfoByAuthId(authId);
|
||||
AuthCloseChannel(authId);
|
||||
}
|
||||
@ -396,6 +419,17 @@ static void OnRecvAuthChannelReply(int32_t authId, const char *data, int32_t len
|
||||
TRANS_LOGE(TRANS_SVC, "can not find channel info by auth id");
|
||||
return;
|
||||
}
|
||||
TransEventExtra extra = {
|
||||
.peerNetworkId = NULL,
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.socketName = info.appInfo.myData.sessionName,
|
||||
.channelId = info.appInfo.myData.channelId,
|
||||
.channelType = CHANNEL_TYPE_AUTH,
|
||||
.authId = authId,
|
||||
.linkType = info.connOpt.type
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
int32_t ret = TransAuthChannelMsgUnpack(data, &info.appInfo, len);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SVC, "unpackReply failed");
|
||||
@ -406,6 +440,8 @@ static void OnRecvAuthChannelReply(int32_t authId, const char *data, int32_t len
|
||||
TRANS_LOGE(TRANS_SVC, "ProcessDataConfig failed");
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
ret = NotifyOpenAuthChannelSuccess(&info.appInfo, false);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SVC, "NotifyOpenAuthChannelSuccess failed");
|
||||
@ -413,6 +449,9 @@ static void OnRecvAuthChannelReply(int32_t authId, const char *data, int32_t len
|
||||
}
|
||||
return;
|
||||
EXIT_ERR:
|
||||
extra.result = EVENT_STAGE_RESULT_FAILED;
|
||||
extra.errcode = ret;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
AuthCloseChannel(authId);
|
||||
DelAuthChannelInfoByChanId((int32_t)(info.appInfo.myData.channelId));
|
||||
(void)NotifyOpenAuthChannelFailed((const char *)(info.appInfo.myData.pkgName),
|
||||
@ -727,12 +766,27 @@ int32_t TransOpenAuthMsgChannel(const char *sessionName, const ConnectOption *co
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
*channelId = (int32_t)channel->appInfo.myData.channelId;
|
||||
channel->appInfo.timeStart = GetSoftbusRecordTimeMillis();
|
||||
channel->appInfo.connectType = connOpt->type;
|
||||
TransEventExtra extra = {
|
||||
.peerNetworkId = NULL,
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.socketName = sessionName,
|
||||
.channelId = *channelId,
|
||||
.channelType = CHANNEL_TYPE_AUTH,
|
||||
.linkType = connOpt->type
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_START_CONNECT, extra);
|
||||
int32_t authId = AuthOpenChannel(connOpt->socketOption.addr, connOpt->socketOption.port);
|
||||
if (authId < 0) {
|
||||
TRANS_LOGE(TRANS_SVC, "AuthOpenChannel failed");
|
||||
SoftBusFree(channel);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
extra.authId = authId;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_START_CONNECT, extra);
|
||||
channel->authId = authId;
|
||||
if (SoftBusMutexLock(&g_authChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SVC, "SoftBusMutexLock failed");
|
||||
@ -747,6 +801,8 @@ int32_t TransOpenAuthMsgChannel(const char *sessionName, const ConnectOption *co
|
||||
(void)SoftBusMutexUnlock(&g_authChannelList->lock);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
extra.result = 0;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_START, extra);
|
||||
if (TransPostAuthChannelMsg(&channel->appInfo, authId, AUTH_CHANNEL_REQ) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SVC, "TransPostAuthRequest failed");
|
||||
AuthCloseChannel(channel->authId);
|
||||
@ -754,6 +810,8 @@ int32_t TransOpenAuthMsgChannel(const char *sessionName, const ConnectOption *co
|
||||
(void)SoftBusMutexUnlock(&g_authChannelList->lock);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_START, extra);
|
||||
(void)SoftBusMutexUnlock(&g_authChannelList->lock);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
@ -42,17 +42,19 @@ static int32_t TransServerOnChannelOpened(const char *pkgName, int32_t pid, cons
|
||||
}
|
||||
int64_t timeStart = channel->timeStart;
|
||||
int64_t timediff = GetSoftbusRecordTimeMillis() - timeStart;
|
||||
if (!channel->isServer) {
|
||||
TransEventExtra extra = {
|
||||
.calleePkg = NULL,
|
||||
.peerNetworkId = channel->peerDeviceId,
|
||||
.linkType = channel->linkType,
|
||||
.channelId = channel->channelId,
|
||||
.costTime = (int32_t)timediff,
|
||||
.result = EVENT_STAGE_RESULT_OK,
|
||||
.callerPkg = pkgName,
|
||||
.socketName = sessionName
|
||||
};
|
||||
TransEventExtra extra = {
|
||||
.calleePkg = NULL,
|
||||
.peerNetworkId = channel->peerDeviceId,
|
||||
.linkType = channel->connectType,
|
||||
.channelId = channel->channelId,
|
||||
.costTime = (int32_t)timediff,
|
||||
.result = EVENT_STAGE_RESULT_OK,
|
||||
.callerPkg = pkgName,
|
||||
.socketName = sessionName
|
||||
};
|
||||
if (channel->isServer) {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
} else {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
}
|
||||
SoftbusRecordOpenSessionKpi(pkgName, channel->linkType, SOFTBUS_EVT_OPEN_SESSION_SUCC, timediff);
|
||||
|
@ -437,7 +437,8 @@ int32_t TransOpenChannel(const SessionParam *param, TransInfo *transInfo)
|
||||
.callerPkg = appInfo->myData.pkgName,
|
||||
.socketName = appInfo->myData.sessionName,
|
||||
.dataType = appInfo->businessType,
|
||||
.peerNetworkId = appInfo->peerNetWorkId
|
||||
.peerNetworkId = appInfo->peerNetWorkId,
|
||||
.result = EVENT_STAGE_RESULT_OK
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_START, extra);
|
||||
errCode = TransGetLaneInfo(param, &connInfo, &laneId);
|
||||
@ -458,6 +459,8 @@ int32_t TransOpenChannel(const SessionParam *param, TransInfo *transInfo)
|
||||
SOFTBUS_EVT_OPEN_SESSION_FAIL, GetSoftbusRecordTimeMillis() - timeStart);
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
appInfo->connectType = connOpt.type;
|
||||
extra.linkType = connOpt.type;
|
||||
FillAppInfo(appInfo, param, transInfo, &connInfo);
|
||||
TransOpenChannelSetModule(transInfo->channelType, &connOpt);
|
||||
TRANS_LOGI(TRANS_CTRL, "laneId=%u get channelType=%u.", laneId, transInfo->channelType);
|
||||
@ -566,34 +569,52 @@ EXIT_ERR:
|
||||
int32_t TransOpenAuthChannel(const char *sessionName, const ConnectOption *connOpt,
|
||||
const char *reqId)
|
||||
{
|
||||
TransEventExtra extra = {
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.socketName = NULL,
|
||||
.peerNetworkId = NULL,
|
||||
.channelType = CHANNEL_TYPE_AUTH,
|
||||
.result = EVENT_STAGE_RESULT_OK
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_START, extra);
|
||||
int32_t channelId = INVALID_CHANNEL_ID;
|
||||
if (!IsValidString(sessionName, SESSION_NAME_SIZE_MAX) || connOpt == NULL) {
|
||||
return channelId;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
|
||||
extra.socketName = sessionName;
|
||||
extra.linkType = connOpt->type;
|
||||
if (connOpt->type == CONNECT_TCP) {
|
||||
if (TransOpenAuthMsgChannel(sessionName, connOpt, &channelId, reqId) != SOFTBUS_OK) {
|
||||
return INVALID_CHANNEL_ID;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
} else if (connOpt->type == CONNECT_BR || connOpt->type == CONNECT_BLE) {
|
||||
AppInfo *appInfo = GetAuthAppInfo(sessionName);
|
||||
if (appInfo == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "GetAuthAppInfo failed");
|
||||
return INVALID_CHANNEL_ID;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
appInfo->connectType = connOpt->type;
|
||||
if (strcpy_s(appInfo->reqId, REQ_ID_SIZE_MAX, reqId) != EOK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "strcpy_s reqId failed");
|
||||
SoftBusFree(appInfo);
|
||||
return INVALID_CHANNEL_ID;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
if (TransProxyOpenProxyChannel(appInfo, connOpt, &channelId) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "proxy channel err");
|
||||
SoftBusFree(appInfo);
|
||||
return INVALID_CHANNEL_ID;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
SoftBusFree(appInfo);
|
||||
} else {
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
return channelId;
|
||||
EXIT_ERR:
|
||||
extra.result = EVENT_STAGE_RESULT_FAILED;
|
||||
extra.errcode = SOFTBUS_ERR;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
return INVALID_CHANNEL_ID;
|
||||
}
|
||||
|
||||
static uint32_t MergeStatsInterval(const uint32_t *data, uint32_t left, uint32_t right)
|
||||
|
@ -77,6 +77,7 @@ static int32_t NotifyNormalChannelOpened(int32_t channelId, const AppInfo *appIn
|
||||
}
|
||||
info.timeStart = appInfo->timeStart;
|
||||
info.linkType = appInfo->linkType;
|
||||
info.connectType = appInfo->connectType;
|
||||
|
||||
int32_t ret = SOFTBUS_ERR;
|
||||
if (appInfo->appType != APP_TYPE_AUTH) {
|
||||
@ -127,7 +128,11 @@ int32_t OnProxyChannelOpened(int32_t channelId, const AppInfo *appInfo, unsigned
|
||||
.errcode = ret,
|
||||
.result = (ret == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
if (!isServer) {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
} else if (ret != SOFTBUS_OK) {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
}
|
||||
TRANS_LOGI(TRANS_CTRL, "on open ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
@ -161,7 +166,7 @@ int32_t OnProxyChannelOpenFailed(int32_t channelId, const AppInfo *appInfo, int3
|
||||
TransEventExtra extra = {
|
||||
.calleePkg = NULL,
|
||||
.peerNetworkId = appInfo->peerData.deviceId,
|
||||
.linkType = appInfo->linkType,
|
||||
.linkType = appInfo->connectType,
|
||||
.channelId = channelId,
|
||||
.costTime = timediff,
|
||||
.errcode = errCode,
|
||||
|
@ -1084,23 +1084,36 @@ void TransProxyProcessHandshakeMsg(const ProxyMessage *msg)
|
||||
(TransProxyAckHandshake(msg->connId, chan, ret) != SOFTBUS_OK)) {
|
||||
TRANS_LOGE(TRANS_CTRL, "ErrHandshake fail, connId=%u.", msg->connId);
|
||||
}
|
||||
TransEventExtra extra = {
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.peerNetworkId = NULL,
|
||||
.channelId = chan->myId,
|
||||
.peerChannelId = chan->peerId,
|
||||
.socketName = chan->appInfo.myData.sessionName,
|
||||
.authId = chan->authId,
|
||||
.connectionId = chan->connId,
|
||||
.linkType = chan->type
|
||||
};
|
||||
if (ret != SOFTBUS_OK) {
|
||||
SoftBusFree(chan);
|
||||
return;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
|
||||
TransCreateConnByConnId(msg->connId);
|
||||
if ((ret = TransProxyAddChanItem(chan)) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "AddChanItem fail");
|
||||
SoftBusFree(chan);
|
||||
return;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_START, extra);
|
||||
if ((ret = OnProxyChannelOpened(chan->channelId, &(chan->appInfo), PROXY_CHANNEL_SERVER)) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "OnProxyChannelOpened fail");
|
||||
(void)TransProxyCloseConnChannelReset(msg->connId, false);
|
||||
TransProxyDelChanByChanId(chan->channelId);
|
||||
return;
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
if (chan->appInfo.fastTransData != NULL && chan->appInfo.fastTransDataSize > 0) {
|
||||
TransProxyFastDataRecv(chan);
|
||||
@ -1111,7 +1124,14 @@ void TransProxyProcessHandshakeMsg(const ProxyMessage *msg)
|
||||
TRANS_LOGE(TRANS_CTRL, "AckHandshake fail");
|
||||
OnProxyChannelClosed(chan->channelId, &(chan->appInfo));
|
||||
TransProxyDelChanByChanId(chan->channelId);
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
return;
|
||||
EXIT_ERR:
|
||||
extra.result = EVENT_STAGE_RESULT_FAILED;
|
||||
extra.errcode = ret;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
}
|
||||
|
||||
void TransProxyProcessResetMsg(const ProxyMessage *msg)
|
||||
|
@ -177,18 +177,34 @@ static int32_t TdcOnConnectEvent(ListenerModule module, int cfd, const ConnectOp
|
||||
}
|
||||
int32_t channelId = GenerateChannelId(true);
|
||||
int32_t ret = TransSrvAddDataBufNode(channelId, cfd); // fd != channelId
|
||||
TransEventExtra extra = {
|
||||
.socketName = NULL,
|
||||
.peerNetworkId = NULL,
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.socketFd = cfd,
|
||||
.channelId = channelId
|
||||
};
|
||||
if (ret != SOFTBUS_OK) {
|
||||
extra.result = EVENT_STAGE_RESULT_FAILED;
|
||||
extra.errcode = ret;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_START_CONNECT, extra);
|
||||
TRANS_LOGE(TRANS_CTRL, "create srv data buf node failed.");
|
||||
ConnShutdownSocket(cfd);
|
||||
return ret;
|
||||
}
|
||||
ret = CreateSessionConnNode(module, cfd, channelId, clientAddr);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
extra.result = EVENT_STAGE_RESULT_FAILED;
|
||||
extra.errcode = ret;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_START_CONNECT, extra);
|
||||
TRANS_LOGE(TRANS_CTRL, "create session conn node fail, delete data buf node.");
|
||||
TransSrvDelDataBufNode(channelId);
|
||||
ConnShutdownSocket(cfd);
|
||||
return ret;
|
||||
}
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_START_CONNECT, extra);
|
||||
TRANS_LOGI(TRANS_CTRL, "tdc conn event cfd=%d, channelId=%d, module=%d.", cfd, channelId, module);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -216,7 +232,12 @@ static void TransProcDataRes(ListenerModule module, int32_t ret, int32_t channel
|
||||
.errcode = ret,
|
||||
.result = EVENT_STAGE_RESULT_FAILED
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
SessionConn conn;
|
||||
if (GetSessionConnById(channelId, &conn) == NULL || !conn.serverSide) {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
} else {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
}
|
||||
DelTrigger(module, fd, READ_TRIGGER);
|
||||
ConnShutdownSocket(fd);
|
||||
NotifyChannelOpenFailed(channelId, ret);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_def.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_hisysevt_transreporter.h"
|
||||
#include "softbus_socket.h"
|
||||
#include "trans_event.h"
|
||||
#include "trans_log.h"
|
||||
@ -37,6 +38,25 @@ static void OnSessionOpenFailProc(const SessionConn *node, int32_t errCode)
|
||||
{
|
||||
TRANS_LOGW(TRANS_CTRL, "OnSesssionOpenFailProc: channelId=%d, side=%d, status=%d",
|
||||
node->channelId, node->serverSide, node->status);
|
||||
int64_t timeStart = node->appInfo.timeStart;
|
||||
int64_t timeDiff = GetSoftbusRecordTimeMillis() - timeStart;
|
||||
TransEventExtra extra = {
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = node->appInfo.myData.pkgName,
|
||||
.channelId = node->appInfo.myData.channelId,
|
||||
.peerChannelId = node->appInfo.peerData.channelId,
|
||||
.peerNetworkId = node->appInfo.peerNetWorkId,
|
||||
.socketName = node->appInfo.myData.sessionName,
|
||||
.linkType = node->appInfo.connectType,
|
||||
.costTime = (int32_t)timeDiff,
|
||||
.errcode = errCode,
|
||||
.result = EVENT_STAGE_RESULT_FAILED
|
||||
};
|
||||
if (!node->serverSide) {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
} else {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
}
|
||||
if (node->serverSide == false) {
|
||||
if (TransTdcOnChannelOpenFailed(node->appInfo.myData.pkgName, node->appInfo.myData.pid,
|
||||
node->channelId, errCode) != SOFTBUS_OK) {
|
||||
|
@ -414,6 +414,7 @@ static int32_t NotifyChannelOpened(int32_t channelId)
|
||||
info.peerDeviceId = buf;
|
||||
info.timeStart = conn.appInfo.timeStart;
|
||||
info.linkType = conn.appInfo.linkType;
|
||||
info.connectType = conn.appInfo.connectType;
|
||||
char pkgName[PKG_NAME_SIZE_MAX] = {0};
|
||||
if (TransTdcGetPkgName(conn.appInfo.myData.sessionName, pkgName, PKG_NAME_SIZE_MAX) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "get pkg name fail.");
|
||||
@ -456,14 +457,18 @@ int32_t NotifyChannelOpenFailed(int32_t channelId, int32_t errCode)
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = conn.appInfo.myData.pkgName,
|
||||
.channelId = conn.appInfo.myData.channelId,
|
||||
.peerNetworkId = conn.appInfo.myData.deviceId,
|
||||
.peerNetworkId = conn.appInfo.peerNetWorkId,
|
||||
.socketName = conn.appInfo.myData.sessionName,
|
||||
.linkType = conn.appInfo.linkType,
|
||||
.linkType = conn.appInfo.connectType,
|
||||
.costTime = timediff,
|
||||
.errcode = errCode,
|
||||
.result = EVENT_STAGE_RESULT_FAILED
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
if (!conn.serverSide) {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
} else {
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_OPEN_CHANNEL_END, extra);
|
||||
}
|
||||
TransAlarmExtra extraAlarm = {
|
||||
.conflictName = NULL,
|
||||
.conflictedName = NULL,
|
||||
@ -808,6 +813,17 @@ static int32_t OpenDataBusRequest(int32_t channelId, uint32_t flags, uint64_t se
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
TransEventExtra extra = {
|
||||
.socketName = conn->appInfo.myData.sessionName,
|
||||
.peerNetworkId = NULL,
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.channelId = channelId,
|
||||
.peerChannelId = conn->appInfo.peerData.channelId,
|
||||
.socketFd = conn->appInfo.fd,
|
||||
.result = EVENT_STAGE_RESULT_OK
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_START, extra);
|
||||
if ((flags & FLAG_AUTH_META) != 0 && !IsMetaSession(conn->appInfo.myData.sessionName)) {
|
||||
char *tmpName = NULL;
|
||||
Anonymize(conn->appInfo.myData.sessionName, &tmpName);
|
||||
@ -869,6 +885,9 @@ static int32_t OpenDataBusRequest(int32_t channelId, uint32_t flags, uint64_t se
|
||||
(void)NotifyChannelClosed(&conn->appInfo, channelId);
|
||||
SoftBusFree(conn);
|
||||
return SOFTBUS_ERR;
|
||||
} else {
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
}
|
||||
|
||||
if (conn->appInfo.routeType == WIFI_P2P) {
|
||||
|
@ -137,6 +137,7 @@ static int32_t NotifyUdpChannelOpened(const AppInfo *appInfo, bool isServerSide)
|
||||
info.autoCloseTime = appInfo->autoCloseTime;
|
||||
info.timeStart = appInfo->timeStart;
|
||||
info.linkType = appInfo->linkType;
|
||||
info.connectType = appInfo->connectType;
|
||||
int32_t ret = g_channelCb->GetPkgNameBySessionName(appInfo->myData.sessionName,
|
||||
(char*)appInfo->myData.pkgName, PKG_NAME_SIZE_MAX);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
@ -180,7 +181,7 @@ int32_t NotifyUdpChannelOpenFailed(const AppInfo *info, int32_t errCode)
|
||||
.channelId = info->myData.channelId,
|
||||
.peerNetworkId = info->myData.deviceId,
|
||||
.socketName = info->myData.sessionName,
|
||||
.linkType = info->linkType,
|
||||
.linkType = info->connectType,
|
||||
.costTime = timediff,
|
||||
.errcode = errCode,
|
||||
.result = EVENT_STAGE_RESULT_FAILED
|
||||
@ -556,12 +557,26 @@ static void TransOnExchangeUdpInfoRequest(int64_t authId, int64_t seq, const cJS
|
||||
(void)memset_s(&info, sizeof(info), 0, sizeof(info));
|
||||
char* errDesc = NULL;
|
||||
|
||||
TransEventExtra extra = {
|
||||
.calleePkg = NULL,
|
||||
.callerPkg = NULL,
|
||||
.socketName = NULL,
|
||||
.peerNetworkId = NULL,
|
||||
.channelType = CHANNEL_TYPE_UDP,
|
||||
.authId = authId
|
||||
};
|
||||
int32_t ret = ParseRequestAppInfo(authId, msg, &info);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "get appinfo failed. ret=%d", ret);
|
||||
errDesc = (char *)"peer device session name not create";
|
||||
goto ERR_EXIT;
|
||||
}
|
||||
if (info.udpChannelOptType == TYPE_UDP_CHANNEL_OPEN) {
|
||||
extra.socketName = info.myData.sessionName;
|
||||
extra.peerChannelId = info.peerData.channelId;
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_START, extra);
|
||||
}
|
||||
ret = ProcessUdpChannelState(&info, true);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "process udp channel state failed. ret=%d", ret);
|
||||
@ -576,9 +591,18 @@ static void TransOnExchangeUdpInfoRequest(int64_t authId, int64_t seq, const cJS
|
||||
ProcessAbnormalUdpChannelState(&info, ret, false);
|
||||
goto ERR_EXIT;
|
||||
}
|
||||
if (info.udpChannelOptType == TYPE_UDP_CHANNEL_OPEN) {
|
||||
extra.result = EVENT_STAGE_RESULT_OK;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
}
|
||||
return;
|
||||
|
||||
ERR_EXIT:
|
||||
if (extra.socketName != NULL && info.udpChannelOptType == TYPE_UDP_CHANNEL_OPEN) {
|
||||
extra.result = EVENT_STAGE_RESULT_FAILED;
|
||||
extra.errcode = ret;
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL_SERVER, EVENT_STAGE_HANDSHAKE_REPLY, extra);
|
||||
}
|
||||
if (SendReplyErrInfo(ret, errDesc, authId, seq) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "send reply error info failed.");
|
||||
}
|
||||
@ -803,8 +827,7 @@ static int32_t OpenAuthConnForUdpNegotiation(UdpChannelInfo *channel)
|
||||
.channelType = CHANNEL_TYPE_UDP,
|
||||
.channelId = channel->info.myData.channelId,
|
||||
.requestId = requestId,
|
||||
.peerNetworkId = channel->info.peerData.deviceId,
|
||||
.result = EVENT_STAGE_RESULT_OK
|
||||
.peerNetworkId = channel->info.peerNetWorkId
|
||||
};
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_START_CONNECT, extra);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
|
Loading…
Reference in New Issue
Block a user