feat: support exit by kill heart-beat thread mode

This commit is contained in:
Alex Duan 2023-04-18 17:12:04 +08:00
parent 6a9bdb9824
commit 0822e82d64
4 changed files with 18 additions and 1 deletions

View File

@ -225,6 +225,9 @@ DLL_EXPORT int taos_get_tables_vgId(TAOS *taos, const char *db, const char *tabl
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
// set heart beat thread quit mode , if quicByKill 1 then kill thread else quit from inner
DLL_EXPORT void taos_set_hb_quit(int8_t quitByKill);
/* --------------------------schemaless INTERFACE------------------------------- */
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);

View File

@ -80,6 +80,7 @@ typedef struct {
int64_t appId;
// ctl
int8_t threadStop;
int8_t quitByKill;
TdThread thread;
TdThreadMutex lock; // used when app init and cleanup
SHashObj* appSummary;

View File

@ -845,7 +845,12 @@ static void hbStopThread() {
return;
}
taosThreadJoin(clientHbMgr.thread, NULL);
// thread quit mode kill or inner exit from self-thread
if (clientHbMgr.quitByKill) {
taosThreadKill(clientHbMgr.thread, 0);
} else {
taosThreadJoin(clientHbMgr.thread, NULL);
}
tscDebug("hb thread stopped");
}
@ -1037,3 +1042,8 @@ void hbDeregisterConn(SAppHbMgr *pAppHbMgr, SClientHbKey connKey) {
atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
}
// set heart beat thread quit mode , if quicByKill 1 then kill thread else quit from inner
void taos_set_hb_quit(int8_t quitByKill) {
clientHbMgr.quitByKill = quitByKill;
}

View File

@ -83,6 +83,9 @@ int main(int argc, char *argv[]) {
#endif
taos_init();
// kill heart-beat thread when quit
taos_set_hb_quit(1);
if (shell.args.is_dump_config) {
shellDumpConfig();
taos_cleanup();