refact: remove the return value of function taosCloseRef

This commit is contained in:
Shengliang Guan 2024-08-19 17:30:10 +08:00
parent 55f7b7d771
commit 5ce7bcad1e
14 changed files with 19 additions and 25 deletions

1
.gitignore vendored
View File

@ -134,3 +134,4 @@ tags
.clangd .clangd
*CMakeCache* *CMakeCache*
*CMakeFiles* *CMakeFiles*
.history/

View File

@ -29,8 +29,7 @@ typedef void (*RefFp)(void *);
int32_t taosOpenRef(int32_t max, RefFp fp); int32_t taosOpenRef(int32_t max, RefFp fp);
// close the reference set, refId is the return value by taosOpenRef // close the reference set, refId is the return value by taosOpenRef
// return 0 if success. On error, -1 is returned, and terrno is set appropriately void taosCloseRef(int32_t rsetId);
int32_t taosCloseRef(int32_t rsetId);
// add ref, p is the pointer to resource or pointer ID // add ref, p is the pointer to resource or pointer ID
// return Reference ID(rid) allocated. On error, -1 is returned, and terrno is set appropriately // return Reference ID(rid) allocated. On error, -1 is returned, and terrno is set appropriately

View File

@ -74,15 +74,11 @@ void taos_cleanup(void) {
int32_t id = clientReqRefPool; int32_t id = clientReqRefPool;
clientReqRefPool = -1; clientReqRefPool = -1;
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) { taosCloseRef(id);
tscWarn("failed to close clientReqRefPool");
}
id = clientConnRefPool; id = clientConnRefPool;
clientConnRefPool = -1; clientConnRefPool = -1;
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) { taosCloseRef(id);
tscWarn("failed to close clientReqRefPool");
}
nodesDestroyAllocatorSet(); nodesDestroyAllocatorSet();
cleanupAppInfo(); cleanupAppInfo();

View File

@ -1184,7 +1184,7 @@ void tmqMgmtClose(void) {
} }
if (tmqMgmt.rsetId >= 0) { if (tmqMgmt.rsetId >= 0) {
(void)taosCloseRef(tmqMgmt.rsetId); taosCloseRef(tmqMgmt.rsetId);
tmqMgmt.rsetId = -1; tmqMgmt.rsetId = -1;
} }
} }

View File

@ -69,7 +69,7 @@ int32_t smaInit() {
if (!smaMgmt.refHash || !smaMgmt.tmrHandle) { if (!smaMgmt.refHash || !smaMgmt.tmrHandle) {
code = terrno; code = terrno;
(void)taosCloseRef(smaMgmt.rsetId); taosCloseRef(smaMgmt.rsetId);
if (smaMgmt.refHash) { if (smaMgmt.refHash) {
taosHashCleanup(smaMgmt.refHash); taosHashCleanup(smaMgmt.refHash);
smaMgmt.refHash = NULL; smaMgmt.refHash = NULL;
@ -103,7 +103,7 @@ void smaCleanUp() {
} }
if (old == 1) { if (old == 1) {
(void)taosCloseRef(smaMgmt.rsetId); taosCloseRef(smaMgmt.rsetId);
taosHashCleanup(smaMgmt.refHash); taosHashCleanup(smaMgmt.refHash);
smaMgmt.refHash = NULL; smaMgmt.refHash = NULL;
taosTmrCleanUp(smaMgmt.tmrHandle); taosTmrCleanUp(smaMgmt.tmrHandle);

View File

@ -31,7 +31,7 @@ int32_t exchangeObjRefPool = -1;
static void cleanupRefPool() { static void cleanupRefPool() {
int32_t ref = atomic_val_compare_exchange_32(&exchangeObjRefPool, exchangeObjRefPool, 0); int32_t ref = atomic_val_compare_exchange_32(&exchangeObjRefPool, exchangeObjRefPool, 0);
(void)taosCloseRef(ref); taosCloseRef(ref);
} }
static void initRefPool() { static void initRefPool() {

View File

@ -74,7 +74,7 @@ void indexCleanup() {
// refacto later // refacto later
taosCleanUpScheduler(indexQhandle); taosCleanUpScheduler(indexQhandle);
taosMemoryFreeClear(indexQhandle); taosMemoryFreeClear(indexQhandle);
(void)taosCloseRef(indexRefMgt); taosCloseRef(indexRefMgt);
} }
typedef struct SIdxColInfo { typedef struct SIdxColInfo {

View File

@ -238,7 +238,7 @@ void nodesDestroyAllocatorSet() {
(void)taosRemoveRef(g_allocatorReqRefPool, refId); (void)taosRemoveRef(g_allocatorReqRefPool, refId);
pAllocator = taosIterateRef(g_allocatorReqRefPool, refId); pAllocator = taosIterateRef(g_allocatorReqRefPool, refId);
} }
(void)taosCloseRef(g_allocatorReqRefPool); taosCloseRef(g_allocatorReqRefPool);
} }
} }

View File

@ -564,7 +564,7 @@ int32_t qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) {
void qwCloseRef(void) { void qwCloseRef(void) {
taosWLockLatch(&gQwMgmt.lock); taosWLockLatch(&gQwMgmt.lock);
if (atomic_load_32(&gQwMgmt.qwNum) <= 0 && gQwMgmt.qwRef >= 0) { if (atomic_load_32(&gQwMgmt.qwNum) <= 0 && gQwMgmt.qwRef >= 0) {
(void)taosCloseRef(gQwMgmt.qwRef); // ignore error taosCloseRef(gQwMgmt.qwRef); // ignore error
gQwMgmt.qwRef = -1; gQwMgmt.qwRef = -1;
} }
taosWUnLockLatch(&gQwMgmt.lock); taosWUnLockLatch(&gQwMgmt.lock);

View File

@ -273,7 +273,7 @@ void schCloseJobRef(void) {
} }
if (schMgmt.jobRef >= 0) { if (schMgmt.jobRef >= 0) {
(void)taosCloseRef(schMgmt.jobRef); taosCloseRef(schMgmt.jobRef);
schMgmt.jobRef = -1; schMgmt.jobRef = -1;
} }
} }

View File

@ -65,9 +65,9 @@ static void streamMetaEnvInit() {
void streamMetaInit() { (void)taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); } void streamMetaInit() { (void)taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); }
void streamMetaCleanup() { void streamMetaCleanup() {
(void)taosCloseRef(streamBackendId); taosCloseRef(streamBackendId);
(void)taosCloseRef(streamBackendCfWrapperId); taosCloseRef(streamBackendCfWrapperId);
(void)taosCloseRef(streamMetaId); taosCloseRef(streamMetaId);
metaRefMgtCleanup(); metaRefMgtCleanup();
streamTimerCleanUp(); streamTimerCleanUp();

View File

@ -736,7 +736,7 @@ int32_t transOpenRefMgt(int size, void (*func)(void*)) {
} }
void transCloseRefMgt(int32_t mgt) { void transCloseRefMgt(int32_t mgt) {
// close ref // close ref
(void)taosCloseRef(mgt); taosCloseRef(mgt);
} }
int64_t transAddExHandle(int32_t refMgt, void* p) { int64_t transAddExHandle(int32_t refMgt, void* p) {
// acquire extern handle // acquire extern handle

View File

@ -75,7 +75,7 @@ void walCleanUp() {
if (old == 1) { if (old == 1) {
walStopThread(); walStopThread();
TAOS_UNUSED(taosCloseRef(tsWal.refSetId)); taosCloseRef(tsWal.refSetId);
wInfo("wal module is cleaned up"); wInfo("wal module is cleaned up");
atomic_store_8(&tsWal.inited, 0); atomic_store_8(&tsWal.inited, 0);
} }

View File

@ -110,13 +110,13 @@ int32_t taosOpenRef(int32_t max, RefFp fp) {
return rsetId; return rsetId;
} }
int32_t taosCloseRef(int32_t rsetId) { void taosCloseRef(int32_t rsetId) {
SRefSet *pSet; SRefSet *pSet;
int32_t deleted = 0; int32_t deleted = 0;
if (rsetId < 0 || rsetId >= TSDB_REF_OBJECTS) { if (rsetId < 0 || rsetId >= TSDB_REF_OBJECTS) {
uTrace("rsetId:%d is invalid, out of range", rsetId); uTrace("rsetId:%d is invalid, out of range", rsetId);
return terrno = TSDB_CODE_REF_INVALID_ID; return;
} }
pSet = tsRefSetList + rsetId; pSet = tsRefSetList + rsetId;
@ -134,8 +134,6 @@ int32_t taosCloseRef(int32_t rsetId) {
(void)taosThreadMutexUnlock(&tsRefMutex); (void)taosThreadMutexUnlock(&tsRefMutex);
if (deleted) taosDecRsetCount(pSet); if (deleted) taosDecRsetCount(pSet);
return 0;
} }
int64_t taosAddRef(int32_t rsetId, void *p) { int64_t taosAddRef(int32_t rsetId, void *p) {