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) int32_t LnnInitNetlinkMonitorImpl(void)
{ {
SoftBusThread tid; 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"); LNN_LOGE(LNN_INIT, "create ip change monitor thread failed");
return SOFTBUS_ERR; return SOFTBUS_ERR;
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -2133,7 +2133,7 @@ static int32_t ConflictGetConnection(const char *udid)
static int32_t BleInitLooper(void) 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) { if (g_bleManagerSyncHandler.handler.looper == NULL) {
CONN_LOGE(CONN_INIT, "init conn ble looper failed"); CONN_LOGE(CONN_INIT, "init conn ble looper failed");
return SOFTBUS_ERR; 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 == SOFTBUS_OK, status, CONN_INIT, "init ble trans failed: init send queue failed, err=%{public}d",
status); status);
status = ConnStartActionAsync(NULL, BleSendTask, NULL); status = ConnStartActionAsync(NULL, BleSendTask, "BleSend_Tsk");
CONN_CHECK_AND_RETURN_RET_LOGW( CONN_CHECK_AND_RETURN_RET_LOGW(
status == SOFTBUS_OK, status, CONN_INIT, "init ble trans failed: start send task failed, err=%{public}d", status == SOFTBUS_OK, status, CONN_INIT, "init ble trans failed: start send task failed, err=%{public}d",
status); status);

View File

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

View File

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

View File

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

View File

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