diff --git a/include/os/os.h b/include/os/os.h index 9112b4922f..023d2b0470 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -51,6 +51,7 @@ extern "C" { #include #include +#include #include "osAtomic.h" #include "osDef.h" diff --git a/include/os/osDef.h b/include/os/osDef.h index 040c4bc7e7..07d360a7c0 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -181,7 +181,8 @@ extern "C" { #endif #else // Windows - #define setThreadName(name) +// #define setThreadName(name) +#define setThreadName(name) do { prctl(PR_SET_NAME, (name)); } while (0) #endif #if defined(_WIN32) diff --git a/source/dnode/mgmt/impl/src/dndMgmt.c b/source/dnode/mgmt/impl/src/dndMgmt.c index 507f9a2644..b127fb1d64 100644 --- a/source/dnode/mgmt/impl/src/dndMgmt.c +++ b/source/dnode/mgmt/impl/src/dndMgmt.c @@ -487,6 +487,8 @@ static void *dnodeThreadRoutine(void *param) { SDnodeMgmt *pMgmt = &pDnode->dmgmt; int32_t ms = pDnode->cfg.statusInterval * 1000; + setThreadName("dnode-hb"); + while (true) { pthread_testcancel(); taosMsleep(ms); diff --git a/source/dnode/vnode/src/vnd/vnodeMgr.c b/source/dnode/vnode/src/vnd/vnodeMgr.c index 730155b75a..40c582910e 100644 --- a/source/dnode/vnode/src/vnd/vnodeMgr.c +++ b/source/dnode/vnode/src/vnd/vnodeMgr.c @@ -98,6 +98,8 @@ int32_t vnodePutReqToVQueryQ(SVnode* pVnode, struct SRpcMsg* pReq) { /* ------------------------ STATIC METHODS ------------------------ */ static void* loop(void* arg) { + setThreadName("vnode-commit"); + SVnodeTask* pTask; for (;;) { pthread_mutex_lock(&(vnodeMgr.mutex)); diff --git a/source/libs/transport/src/rpcMain.c b/source/libs/transport/src/rpcMain.c index d870ae98ab..884246bc91 100644 --- a/source/libs/transport/src/rpcMain.c +++ b/source/libs/transport/src/rpcMain.c @@ -235,7 +235,7 @@ void *rpcOpen(const SRpcInit *pInit) { pRpc = (SRpcInfo *)calloc(1, sizeof(SRpcInfo)); if (pRpc == NULL) return NULL; - if (pInit->label) tstrncpy(pRpc->label, pInit->label, strlen(pInit->label)); + if (pInit->label) tstrncpy(pRpc->label, pInit->label, tListLen(pInit->label)); pRpc->connType = pInit->connType; if (pRpc->connType == TAOS_CONN_CLIENT) {