fix:add thread name

Signed-off-by: xuhengxiang <1072458510@qq.com>
This commit is contained in:
xuhengxiang 2024-03-19 14:59:13 +08:00
parent 676a7c6538
commit f9706b9380
13 changed files with 20 additions and 18 deletions

View File

@ -197,7 +197,10 @@ static void *NetlinkMonitorThread(void *para)
int32_t LnnInitNetlinkMonitorImpl(void)
{
SoftBusThread tid;
if (SoftBusThreadCreate(&tid, NULL, NetlinkMonitorThread, NULL) != 0) {
SoftBusThreadAttr threadAttr;
SoftBusThreadAttrInit(&threadAttr);
threadAttr.taskName = "NetMonitor_Tsk";
if (SoftBusThreadCreate(&tid, &threadAttr, NetlinkMonitorThread, NULL) != 0) {
LNN_LOGE(LNN_INIT, "create ip change monitor thread failed");
return SOFTBUS_ERR;
}

View File

@ -1064,7 +1064,7 @@ static int32_t InitHeartbeatFsm(LnnHeartbeatFsm *hbFsm)
LNN_LOGE(LNN_HEART_BEAT, "format fsm name fail");
return SOFTBUS_ERR;
}
SoftBusLooper *looper = CreateNewLooper("Heartbeat-Looper");
SoftBusLooper *looper = CreateNewLooper("Heartbeat_Lp");
if (looper == NULL) {
LNN_LOGE(LNN_HEART_BEAT, "create looper fail");
return SOFTBUS_ERR;

View File

@ -227,7 +227,7 @@ uint64_t LnnGetSysTimeMs(void)
int32_t LnnInitLaneLooper(void)
{
SoftBusLooper *looper = CreateNewLooper("Lane-looper");
SoftBusLooper *looper = CreateNewLooper("Lane_lp");
if (!looper) {
LNN_LOGE(LNN_LANE, "init laneLooper fail");
return SOFTBUS_ERR;

View File

@ -638,7 +638,7 @@ void LnnNotifyNetworkIdChangeEvent(const char *networkId)
int32_t LnnInitBusCenterEvent(void)
{
int32_t i;
SoftBusLooper *looper = CreateNewLooper("NotifyLooper");
SoftBusLooper *looper = CreateNewLooper("LnnNotify_Lp");
if (looper == NULL) {
LNN_LOGE(LNN_EVENT, "create notify looper fail");
return SOFTBUS_ERR;

View File

@ -207,17 +207,17 @@ static int StartNewLooperThread(SoftBusLooper *looper)
SoftBusThreadAttr threadAttr;
SoftBusThread tid;
SoftBusThreadAttrInit(&threadAttr);
threadAttr.taskName = looper->context->name;
threadAttr.stackSize = MAINLOOP_STACK_SIZE;
int32_t ret = SoftBusThreadCreate(&tid, &threadAttr, LoopTask, looper);
if (ret != SOFTBUS_OK) {
COMM_LOGE(COMM_UTILS, "Init DeathProcTask ThreadAttr failed");
return -1;
return SOFTBUS_ERR;
}
COMM_LOGI(COMM_UTILS, "loop thread creating. name=%{public}s, tid=%{public}d", looper->context->name,
(int)(uintptr_t)tid);
return 0;
return SOFTBUS_OK;
}
static void DumpLooperLocked(const SoftBusLooperContext *context, const SoftBusHandler *handler)
@ -436,7 +436,6 @@ SoftBusLooper *CreateNewLooper(const char *name)
SoftBusFree(looper);
return NULL;
}
if (memcpy_s(context->name, sizeof(context->name), name, strlen(name)) != EOK) {
COMM_LOGE(COMM_UTILS, "memcpy_s fail");
SoftBusFree(looper);
@ -566,14 +565,14 @@ void DestroyLooper(SoftBusLooper *looper)
int LooperInit(void)
{
SoftBusLooper *looper = CreateNewLooper("BusCenter");
SoftBusLooper *looper = CreateNewLooper("BusCenter_Lp");
if (!looper) {
COMM_LOGE(COMM_UTILS, "init BusCenter looper fail.");
return SOFTBUS_ERR;
}
SetLooper(LOOP_TYPE_DEFAULT, looper);
SoftBusLooper *handleFileLooper = CreateNewLooper("HandleFile");
SoftBusLooper *handleFileLooper = CreateNewLooper("Hidumper_Lp");
if (!handleFileLooper) {
COMM_LOGE(COMM_UTILS, "init HandleFile looper fail.");
return SOFTBUS_ERR;

View File

@ -2133,7 +2133,7 @@ static int32_t ConflictGetConnection(const char *udid)
static int32_t BleInitLooper(void)
{
g_bleManagerSyncHandler.handler.looper = CreateNewLooper("conn_ble_looper");
g_bleManagerSyncHandler.handler.looper = CreateNewLooper("Conn_Ble_lp");
if (g_bleManagerSyncHandler.handler.looper == NULL) {
CONN_LOGE(CONN_INIT, "init conn ble looper failed");
return SOFTBUS_ERR;

View File

@ -595,7 +595,7 @@ int32_t ConnBleInitTransModule(ConnBleTransEventListener *listener)
status == SOFTBUS_OK, status, CONN_INIT, "init ble trans failed: init send queue failed, err=%{public}d",
status);
status = ConnStartActionAsync(NULL, BleSendTask, NULL);
status = ConnStartActionAsync(NULL, BleSendTask, "BleSend_Tsk");
CONN_CHECK_AND_RETURN_RET_LOGW(
status == SOFTBUS_OK, status, CONN_INIT, "init ble trans failed: start send task failed, err=%{public}d",
status);

View File

@ -613,7 +613,7 @@ int32_t ConnBrStartServer(void)
}
serverState->available = true;
serverState->serverId = -1;
status = ConnStartActionAsync(serverState, ListenTask, NULL);
status = ConnStartActionAsync(serverState, ListenTask, "BrListen_Tsk");
if (status != SOFTBUS_OK) {
CONN_LOGE(CONN_BR, "start br server failed: error=%{public}d", status);
(void)SoftBusMutexDestroy(&serverState->mutex);

View File

@ -1576,7 +1576,7 @@ static int32_t BrPendConnection(const ConnectOption *option, uint32_t time)
static int32_t BrInitLooper(void)
{
g_brManagerAsyncHandler.handler.looper = CreateNewLooper("br_looper");
g_brManagerAsyncHandler.handler.looper = CreateNewLooper("Conn_Br_lp");
if (g_brManagerAsyncHandler.handler.looper == NULL) {
return SOFTBUS_ERR;
}

View File

@ -493,7 +493,7 @@ int32_t ConnBrTransMuduleInit(SppSocketDriver *sppDriver, ConnBrTransEventListen
CONN_CHECK_AND_RETURN_RET_LOGW(status == SOFTBUS_OK, status, CONN_INIT,
"init br trans module failed: init br send queue failed, error=%{public}d", status);
status = ConnStartActionAsync(NULL, SendHandlerLoop, NULL);
status = ConnStartActionAsync(NULL, SendHandlerLoop, "BrSend_Tsk");
if (status != SOFTBUS_OK) {
return status;
}

View File

@ -1212,7 +1212,7 @@ static int32_t StartSelectThread(void)
break;
}
state->referenceCount = 1;
status = ConnStartActionAsync(state, SelectTask, "OS_selectTsk");
status = ConnStartActionAsync(state, SelectTask, "Select_Tsk");
if (status != SOFTBUS_OK) {
CONN_LOGE(CONN_COMMON, "init lock failed, error=%{public}d", status);
CleanupSelectThreadState(&state);

View File

@ -130,7 +130,7 @@ int32_t CallMethodAsync(WorkFunction function, void *data, int64_t delayTimeMs)
int32_t WifiDirectWorkQueueInit(void)
{
CONN_LOGI(CONN_INIT, "init enter");
SoftBusLooper *looper = CreateNewLooper("WDWQLooper");
SoftBusLooper *looper = CreateNewLooper("WDWQ_Lp");
if (looper == NULL) {
CONN_LOGE(CONN_INIT, "create looper failed");
return SOFTBUS_ERR;

View File

@ -654,7 +654,7 @@ int32_t TransProxyPipelineInit(void)
if (ret != SOFTBUS_OK) {
goto exit;
}
g_manager.looper = CreateNewLooper("proxy_looper");
g_manager.looper = CreateNewLooper("Trans_Proxy_lp");
g_manager.handler.looper = g_manager.looper;
strcpy_s(g_manager.handler.name, strlen(PIPELINEHANDLER_NAME) + 1, PIPELINEHANDLER_NAME);
g_manager.handler.HandleMessage = TransProxyPipelineHandleMessage;