diff --git a/include/common/schema.h b/include/common/schema.h
index 2b19eca76c..ccc91f09ff 100644
--- a/include/common/schema.h
+++ b/include/common/schema.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef _TD_SCHEMA_H_
-#define _TD_SCHEMA_H_
+#ifndef _TD_COMMON_SCHEMA_H_
+#define _TD_COMMON_SCHEMA_H_
#include "os.h"
@@ -100,4 +100,4 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
}
#endif
-#endif /*_TD_SCHEMA_H_*/
\ No newline at end of file
+#endif /*_TD_COMMON_SCHEMA_H_*/
\ No newline at end of file
diff --git a/include/common/taosdef.h b/include/common/taosdef.h
index dd7dfd9518..bae3dcf5e6 100644
--- a/include/common/taosdef.h
+++ b/include/common/taosdef.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef _TD_COMMON_TAOS_DEF_H
-#define _TD_COMMON_TAOS_DEF_H
+#ifndef _TD_COMMON_TAOS_DEF_H_
+#define _TD_COMMON_TAOS_DEF_H_
#ifdef __cplusplus
extern "C" {
@@ -76,4 +76,4 @@ extern char *qtypeStr[];
}
#endif
-#endif /*_TD_COMMON_TAOS_DEF_H*/
+#endif /*_TD_COMMON_TAOS_DEF_H_*/
diff --git a/include/common/taoserror.h b/include/common/taoserror.h
index d59b88c7e6..7e30601037 100644
--- a/include/common/taoserror.h
+++ b/include/common/taoserror.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TAOSERROR_H
-#define TDENGINE_TAOSERROR_H
+#ifndef _TD_COMMON_TAOS_ERROR_H_
+#define _TD_COMMON_TAOS_ERROR_H_
#ifdef __cplusplus
extern "C" {
@@ -463,4 +463,4 @@ int32_t* taosGetErrno();
}
#endif
-#endif //TDENGINE_TAOSERROR_H
+#endif /*_TD_COMMON_TAOS_ERROR_H_*/
diff --git a/include/common/taosmsg.h b/include/common/taosmsg.h
index 76743f10a4..be2f690752 100644
--- a/include/common/taosmsg.h
+++ b/include/common/taosmsg.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TAOSMSG_H
-#define TDENGINE_TAOSMSG_H
+#ifndef _TD_COMMON_TAOS_MSG_H_
+#define _TD_COMMON_TAOS_MSG_H_
#ifdef __cplusplus
extern "C" {
@@ -961,4 +961,4 @@ typedef struct {
}
#endif
-#endif
+#endif /*_TD_COMMON_TAOS_MSG_H_*/
diff --git a/include/common/tarithoperator.h b/include/common/tarithoperator.h
index 27e8871e2f..e47cb5c1cb 100644
--- a/include/common/tarithoperator.h
+++ b/include/common/tarithoperator.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_QARITHMETICOPERATOR_H
-#define TDENGINE_QARITHMETICOPERATOR_H
+#ifndef _TD_COMMON_QARITHMETICOPERATOR_H_
+#define _TD_COMMON_QARITHMETICOPERATOR_H_
#ifdef __cplusplus
extern "C" {
@@ -29,4 +29,4 @@ _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr);
}
#endif
-#endif // TDENGINE_TSYNTAXTREEFUNCTION_H
+#endif /*_TD_COMMON_QARITHMETICOPERATOR_H_*/
diff --git a/include/common/tcmdtype.h b/include/common/tcmdtype.h
index 918763ebb4..e37996b9c7 100644
--- a/include/common/tcmdtype.h
+++ b/include/common/tcmdtype.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TSQLMSGTYPE_H
-#define TDENGINE_TSQLMSGTYPE_H
+#ifndef _TD_COMMON_SQLMSGTYPE_H_
+#define _TD_COMMON_SQLMSGTYPE_H_
#ifdef __cplusplus
extern "C" {
@@ -116,4 +116,4 @@ extern char *sqlCmd[];
}
#endif
-#endif // TDENGINE_TSQLMSGTYPE_H
+#endif /*_TD_COMMON_SQLMSGTYPE_H_*/
diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h
index ab7baea2d7..e348381ae0 100644
--- a/include/common/tdataformat.h
+++ b/include/common/tdataformat.h
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#ifndef _TD_DATA_FORMAT_H_
-#define _TD_DATA_FORMAT_H_
+#ifndef _TD_COMMON_DATA_FORMAT_H_
+#define _TD_COMMON_DATA_FORMAT_H_
#include "os.h"
#include "talgo.h"
@@ -813,4 +813,4 @@ static FORCE_INLINE char *payloadNextCol(char *pCol) { return (char *)POINTER_SH
}
#endif
-#endif // _TD_DATA_FORMAT_H_
+#endif /*_TD_COMMON_DATA_FORMAT_H_*/
diff --git a/include/common/texpr.h b/include/common/texpr.h
index 0ede2e1e6f..e28f8644ed 100644
--- a/include/common/texpr.h
+++ b/include/common/texpr.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TEXPR_H
-#define TDENGINE_TEXPR_H
+#ifndef _TD_COMMON_EXPR_H_
+#define _TD_COMMON_EXPR_H_
#ifdef __cplusplus
extern "C" {
@@ -104,4 +104,4 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len);
}
#endif
-#endif // TDENGINE_TEXPR_H
+#endif /*_TD_COMMON_EXPR_H_*/
diff --git a/include/common/tglobal.h b/include/common/tglobal.h
index 867d4ae2dd..ffabe0d935 100644
--- a/include/common/tglobal.h
+++ b/include/common/tglobal.h
@@ -13,13 +13,15 @@
* along with this program. If not, see .
*/
-#ifndef _TD_COMMON_GLOBAL_H
-#define _TD_COMMON_GLOBAL_H
+#ifndef _TD_COMMON_GLOBAL_H_
+#define _TD_COMMON_GLOBAL_H_
#ifdef __cplusplus
extern "C" {
#endif
+#include "tdef.h"
+
// cluster
extern char tsFirst[];
extern char tsSecond[];
@@ -186,7 +188,7 @@ extern char Compressor[];
extern int8_t tsDeadLockKillQuery;
typedef struct {
- char dir[128];
+ char dir[TSDB_FILENAME_LEN];
int level;
int primary;
} SDiskCfg;
@@ -208,4 +210,4 @@ void taosPrintDataDirCfg();
}
#endif
-#endif
+#endif /*_TD_COMMON_GLOBAL_H_*/
diff --git a/include/common/tlocale.h b/include/common/tlocale.h
index 91ae386622..d809c75d67 100644
--- a/include/common/tlocale.h
+++ b/include/common/tlocale.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_COMMON_LOCALE_H
-#define TDENGINE_COMMON_LOCALE_H
+#ifndef _TD_COMMON_LOCALE_H_
+#define _TD_COMMON_LOCALE_H_
#ifdef __cplusplus
extern "C" {
@@ -24,6 +24,6 @@ void tsSetLocale();
#ifdef __cplusplus
}
-#endif
+#endif /*_TD_COMMON_LOCALE_H_*/
#endif
diff --git a/include/common/tname.h b/include/common/tname.h
index b29a535ec2..5809d09b15 100644
--- a/include/common/tname.h
+++ b/include/common/tname.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_NAME_H
-#define TDENGINE_NAME_H
+#ifndef _TD_COMMON_NAME_H_
+#define _TD_COMMON_NAME_H_
#include "os.h"
#include "taosmsg.h"
@@ -136,4 +136,4 @@ int32_t tNameSetAcctId(SName* dst, const char* acct);
int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken);
-#endif // TDENGINE_NAME_H
+#endif /*_TD_COMMON_NAME_H_*/
diff --git a/include/common/trow.h b/include/common/trow.h
index c6e95d5d61..be4b7af32a 100644
--- a/include/common/trow.h
+++ b/include/common/trow.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef _TD_TROW_H_
-#define _TD_TROW_H_
+#ifndef _TD_COMMON_ROW_H_
+#define _TD_COMMON_ROW_H_
#ifdef __cplusplus
extern "C" {
@@ -24,4 +24,4 @@ extern "C" {
}
#endif
-#endif /*_TD_TROW_H_*/
\ No newline at end of file
+#endif /*_TD_COMMON_ROW_H_*/
\ No newline at end of file
diff --git a/include/common/ttimezone.h b/include/common/ttimezone.h
index 0ae983dba0..cc50a29d57 100644
--- a/include/common/ttimezone.h
+++ b/include/common/ttimezone.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_COMMON_TIMEZONE_H
-#define TDENGINE_COMMON_TIMEZONE_H
+#ifndef _TD_COMMON_TIMEZONE_H_
+#define _TD_COMMON_TIMEZONE_H_
#ifdef __cplusplus
extern "C" {
@@ -26,4 +26,4 @@ void tsSetTimeZone();
}
#endif
-#endif
+#endif /*_TD_COMMON_TIMEZONE_H_*/
diff --git a/include/common/ttoken.h b/include/common/ttoken.h
index f62329183f..552e52636f 100644
--- a/include/common/ttoken.h
+++ b/include/common/ttoken.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TTOKEN_H
-#define TDENGINE_TTOKEN_H
+#ifndef _TD_COMMON_TOKEN_H_
+#define _TD_COMMON_TOKEN_H_
#ifdef __cplusplus
extern "C" {
@@ -189,4 +189,4 @@ SStrToken taosTokenDup(SStrToken* pToken, char* buf, int32_t len);
}
#endif
-#endif // TDENGINE_TTOKEN_H
+#endif /*_TD_COMMON_TOKEN_H_*/
diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h
index 9b0ad2cf13..5f9fe5134b 100644
--- a/include/common/ttokendef.h
+++ b/include/common/ttokendef.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TTOKENDEF_H
-#define TDENGINE_TTOKENDEF_H
+#ifndef _TD_COMMON_TOKEN_DEF_H_
+#define _TD_COMMON_TOKEN_DEF_H_
#define TK_ID 1
#define TK_BOOL 2
@@ -223,6 +223,6 @@
#define TK_FILE 306
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
-#endif
+#endif /*_TD_COMMON_TOKEN_DEF_H_*/
diff --git a/include/common/ttype.h b/include/common/ttype.h
index 42296f80ba..2150b818d7 100644
--- a/include/common/ttype.h
+++ b/include/common/ttype.h
@@ -1,5 +1,5 @@
-#ifndef TDENGINE_TTYPE_H
-#define TDENGINE_TTYPE_H
+#ifndef _TD_COMMON_TYPE_H_
+#define _TD_COMMON_TYPE_H_
#ifdef __cplusplus
extern "C" {
@@ -178,4 +178,4 @@ int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bo
}
#endif
-#endif // TDENGINE_TTYPE_H
+#endif /*_TD_COMMON_TYPE_H_*/
diff --git a/include/common/tvariant.h b/include/common/tvariant.h
index c69a662846..f95eb281cf 100644
--- a/include/common/tvariant.h
+++ b/include/common/tvariant.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TVARIANT_H
-#define TDENGINE_TVARIANT_H
+#ifndef _TD_COMMON_VARIANT_H_
+#define _TD_COMMON_VARIANT_H_
#include "tarray.h"
#include "ttoken.h"
@@ -61,4 +61,4 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type);
}
#endif
-#endif // TDENGINE_TVARIANT_H
+#endif /*_TD_COMMON_VARIANT_H_*/
diff --git a/include/os/osDef.h b/include/os/osDef.h
index 8db9c6584f..2b3678ac67 100644
--- a/include/os/osDef.h
+++ b/include/os/osDef.h
@@ -102,15 +102,6 @@ extern "C" {
#define UNUSED_FUNC
#endif
-// TODO: replace and remove code below
-#define CHAR_BYTES sizeof(char)
-#define SHORT_BYTES sizeof(int16_t)
-#define INT_BYTES sizeof(int32_t)
-#define LONG_BYTES sizeof(int64_t)
-#define FLOAT_BYTES sizeof(float)
-#define DOUBLE_BYTES sizeof(double)
-#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*)
-
#ifdef tListLen
#undefine tListLen
#endif
diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h
index 62b52827d6..688fb8f7ef 100644
--- a/include/os/osSysinfo.h
+++ b/include/os/osSysinfo.h
@@ -20,7 +20,7 @@
extern "C" {
#endif
-#define TSDB_LOCALE_LEN 64
+#define TSDB_LOCALE_LEN 64
#define TSDB_TIMEZONE_LEN 96
extern int64_t tsPageSize;
diff --git a/include/util/hashfunc.h b/include/util/hashfunc.h
index 04c2d1fcf0..3992d8b02e 100644
--- a/include/util/hashfunc.h
+++ b/include/util/hashfunc.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef _TD_UTIL_HASH_FUNC_H
-#define _TD_UTIL_HASH_FUNC_H
+#ifndef _TD_UTIL_HASHFUNC_H
+#define _TD_UTIL_HASHFUNC_H
#include "os.h"
@@ -48,4 +48,4 @@ _hash_fn_t taosGetDefaultHashFunction(int32_t type);
_equal_fn_t taosGetDefaultEqualFunction(int32_t type);
-#endif /*_TD_UTIL_HASH_FUNC_H*/
+#endif /*_TD_UTIL_HASHFUNC_H*/
diff --git a/include/util/tchecksum.h b/include/util/tchecksum.h
index 12ca3a5443..c1907b0c46 100644
--- a/include/util/tchecksum.h
+++ b/include/util/tchecksum.h
@@ -13,22 +13,14 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TCHECKSUM_H
-#define TDENGINE_TCHECKSUM_H
+#ifndef _TD_UTIL_CHECKSUM_H
+#define _TD_UTIL_CHECKSUM_H
#ifdef __cplusplus
extern "C" {
#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
+#include "os.h"
#include "tcrc32c.h"
#include "tutil.h"
@@ -64,4 +56,4 @@ static FORCE_INLINE int taosCheckChecksumWhole(const uint8_t *stream, uint32_t s
}
#endif
-#endif // TDENGINE_TCHECKSUM_H
+#endif /*_TD_UTIL_CHECKSUM_H*/
diff --git a/include/util/tcompare.h b/include/util/tcompare.h
index 1125516d34..4b2c583b4b 100644
--- a/include/util/tcompare.h
+++ b/include/util/tcompare.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TCOMPARE_H
-#define TDENGINE_TCOMPARE_H
+#ifndef _TD_UTIL_COMPARE_H
+#define _TD_UTIL_COMPARE_H
#ifdef __cplusplus
extern "C" {
@@ -93,4 +93,4 @@ int32_t compareWStrPatternComp(const void* pLeft, const void* pRight);
}
#endif
-#endif // TDENGINE_TCOMPARE_H
+#endif /*_TD_UTIL_COMPARE_H*/
diff --git a/include/util/tconfig.h b/include/util/tconfig.h
index 68fa4128ae..bc56d21b3a 100644
--- a/include/util/tconfig.h
+++ b/include/util/tconfig.h
@@ -87,8 +87,8 @@ bool taosReadGlobalCfg();
void taosPrintGlobalCfg();
void taosDumpGlobalCfg();
-void taosInitConfigOption(SGlobalCfg cfg);
-SGlobalCfg * taosGetConfigOption(const char *option);
+void taosInitConfigOption(SGlobalCfg cfg);
+SGlobalCfg *taosGetConfigOption(const char *option);
#ifdef __cplusplus
}
diff --git a/include/util/tdef.h b/include/util/tdef.h
index b09f39fc32..04a06d1275 100644
--- a/include/util/tdef.h
+++ b/include/util/tdef.h
@@ -33,6 +33,15 @@ extern "C" {
// Bytes for each type.
extern const int32_t TYPE_BYTES[15];
+// TODO: replace and remove code below
+#define CHAR_BYTES sizeof(char)
+#define SHORT_BYTES sizeof(int16_t)
+#define INT_BYTES sizeof(int32_t)
+#define LONG_BYTES sizeof(int64_t)
+#define FLOAT_BYTES sizeof(float)
+#define DOUBLE_BYTES sizeof(double)
+#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*)
+
#define TSDB_KEYSIZE sizeof(TSKEY)
#if LINUX
diff --git a/include/util/tfile.h b/include/util/tfile.h
index 155c127eff..ff62c9e341 100644
--- a/include/util/tfile.h
+++ b/include/util/tfile.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TFILE_H
-#define TDENGINE_TFILE_H
+#ifndef _TD_UTIL_FILE_H
+#define _TD_UTIL_FILE_H
#ifdef __cplusplus
extern "C" {
@@ -44,4 +44,4 @@ int32_t tfFtruncate(int64_t tfd, int64_t length);
}
#endif
-#endif // TDENGINE_TFILE_H
+#endif /*_TD_UTIL_FILE_H*/
diff --git a/include/util/tfunctional.h b/include/util/tfunctional.h
index 70f54e921d..c96f997f06 100644
--- a/include/util/tfunctional.h
+++ b/include/util/tfunctional.h
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#ifndef TD_TFUNCTIONAL_H
-#define TD_TFUNCTIONAL_H
+#ifndef _TD_UTIL_FUNCTIONAL_H
+#define _TD_UTIL_FUNCTIONAL_H
#ifdef __cplusplus
extern "C" {
@@ -53,4 +53,4 @@ void voidInvoke(tVoidSavedFunc* const pSavedFunc);
}
#endif
-#endif
+#endif /*_TD_UTIL_FUNCTIONAL_H*/
diff --git a/include/util/tidpool.h b/include/util/tidpool.h
index e4439439ce..1a977fd04c 100644
--- a/include/util/tidpool.h
+++ b/include/util/tidpool.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TIDPOOL_H
-#define TDENGINE_TIDPOOL_H
+#ifndef _TD_UTIL_IDPOOL_H
+#define _TD_UTIL_IDPOOL_H
#ifdef __cplusplus
extern "C" {
@@ -40,4 +40,4 @@ bool taosIdPoolMarkStatus(void *handle, int id);
}
#endif
-#endif
+#endif /*_TD_UTIL_IDPOOL_H*/
diff --git a/include/util/tkey.h b/include/util/tkey.h
index b71cdb2868..197cfff958 100644
--- a/include/util/tkey.h
+++ b/include/util/tkey.h
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TKEY_H
-#define TDENGINE_TKEY_H
+#ifndef _TD_UTIL_KEY_H
+#define _TD_UTIL_KEY_H
#ifdef __cplusplus
extern "C" {
@@ -28,4 +28,4 @@ char * taosDesDecode(int64_t key, char *src, int len);
}
#endif
-#endif
\ No newline at end of file
+#endif /*_TD_UTIL_KEY_H*/
\ No newline at end of file
diff --git a/include/util/tlog.h b/include/util/tlog.h
index a99085923e..5c6e59b103 100644
--- a/include/util/tlog.h
+++ b/include/util/tlog.h
@@ -20,7 +20,6 @@
extern "C" {
#endif
-
// log
extern int8_t tsAsyncLog;
extern int32_t tsNumOfLogLines;
diff --git a/include/util/tlosertree.h b/include/util/tlosertree.h
index 58f2ca8c5c..d6ffde82ca 100644
--- a/include/util/tlosertree.h
+++ b/include/util/tlosertree.h
@@ -13,15 +13,13 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TLOSERTREE_H
-#define TDENGINE_TLOSERTREE_H
+#ifndef _TD_UTIL_LOSERTREE_H
+#define _TD_UTIL_LOSERTREE_H
#ifdef __cplusplus
extern "C" {
#endif
-#include
-
typedef int (*__merge_compare_fn_t)(const void *, const void *, void *param);
typedef struct SLoserTreeNode {
@@ -51,4 +49,4 @@ void tLoserTreeDisplay(SLoserTreeInfo *pTree);
}
#endif
-#endif // TDENGINE_TLOSERTREE_H
+#endif /*_TD_UTIL_LOSERTREE_H*/
diff --git a/include/util/tmd5.h b/include/util/tmd5.h
index d7fd038f37..329f4acf11 100644
--- a/include/util/tmd5.h
+++ b/include/util/tmd5.h
@@ -22,10 +22,8 @@
***********************************************************************
*/
-#ifndef _taos_md5_header_
-#define _taos_md5_header_
-
-#include
+#ifndef _TD_UTIL_MD5_H
+#define _TD_UTIL_MD5_H
typedef struct {
uint32_t i[2]; /* number of _bits_ handled mod 2^64 */
@@ -38,4 +36,4 @@ void MD5Init(MD5_CTX *mdContext);
void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen);
void MD5Final(MD5_CTX *mdContext);
-#endif
+#endif /*_TD_UTIL_MD5_H*/
diff --git a/include/util/tmempool.h b/include/util/tmempool.h
index f2c6a0ef00..3e3db738a9 100644
--- a/include/util/tmempool.h
+++ b/include/util/tmempool.h
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TMEMPOOL_H
-#define TDENGINE_TMEMPOOL_H
+#ifndef _TD_UTIL_MEMPOOL_H
+#define _TD_UTIL_MEMPOOL_H
#ifdef __cplusplus
extern "C" {
@@ -33,4 +33,4 @@ void taosMemPoolCleanUp(mpool_h handle);
}
#endif
-#endif
+#endif /*_TD_UTIL_MEMPOOL_H*/
diff --git a/include/util/tnote.h b/include/util/tnote.h
index 7511b61f41..e4f28d8cff 100644
--- a/include/util/tnote.h
+++ b/include/util/tnote.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TNOTE_H
-#define TDENGINE_TNOTE_H
+#ifndef _TD_UTIL_NOTE_H
+#define _TD_UTIL_NOTE_H
#ifdef __cplusplus
extern "C" {
@@ -61,4 +61,4 @@ void taosNotePrintBuffer(SNoteObj *pNote, char *buffer, int32_t len);
}
#endif
-#endif
+#endif /*_TD_UTIL_NOTE_H*/
diff --git a/include/util/tqueue.h b/include/util/tqueue.h
index c3051464e5..cd897435fa 100644
--- a/include/util/tqueue.h
+++ b/include/util/tqueue.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TAOS_QUEUE_H
-#define TAOS_QUEUE_H
+#ifndef _TD_UTIL_QUEUE_H
+#define _TD_UTIL_QUEUE_H
#ifdef __cplusplus
extern "C" {
@@ -71,6 +71,6 @@ int taosGetQsetItemsNumber(taos_qset param);
}
#endif
-#endif
+#endif /*_TD_UTIL_QUEUE_H*/
diff --git a/include/util/tref.h b/include/util/tref.h
index 085c10c551..cc7d075f52 100644
--- a/include/util/tref.h
+++ b/include/util/tref.h
@@ -14,8 +14,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TREF_H
-#define TDENGINE_TREF_H
+#ifndef _TD_UTIL_REF_H
+#define _TD_UTIL_REF_H
#ifdef __cplusplus
extern "C" {
@@ -74,4 +74,4 @@ void demoIterateRefs(int rsetId) {
}
#endif
-#endif // TDENGINE_TREF_H
+#endif /*_TD_UTIL_REF_H*/
diff --git a/include/util/tsched.h b/include/util/tsched.h
index a1591512c1..d60c0c5ad4 100644
--- a/include/util/tsched.h
+++ b/include/util/tsched.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TSCHED_H
-#define TDENGINE_TSCHED_H
+#ifndef _TD_UTIL_SCHED_H
+#define _TD_UTIL_SCHED_H
#ifdef __cplusplus
extern "C" {
@@ -68,4 +68,4 @@ void taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg);
}
#endif
-#endif // TDENGINE_TSCHED_H
+#endif /*_TD_UTIL_SCHED_H*/
diff --git a/include/util/tscompression.h b/include/util/tscompression.h
index 6f722533ac..1e76b5198a 100644
--- a/include/util/tscompression.h
+++ b/include/util/tscompression.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TSCOMPRESSION_H
-#define TDENGINE_TSCOMPRESSION_H
+#ifndef _TD_UTIL_COMPRESSION_H
+#define _TD_UTIL_COMPRESSION_H
#ifdef __cplusplus
extern "C" {
@@ -366,4 +366,4 @@ static FORCE_INLINE int tsDecompressTimestamp(const char *const input, int compr
}
#endif
-#endif // TDENGINE_TSCOMPRESSION_H
\ No newline at end of file
+#endif /*_TD_UTIL_COMPRESSION_H*/
\ No newline at end of file
diff --git a/include/util/tskiplist.h b/include/util/tskiplist.h
index 9aa225078b..8e991727a7 100644
--- a/include/util/tskiplist.h
+++ b/include/util/tskiplist.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TSKIPLIST_H
-#define TDENGINE_TSKIPLIST_H
+#ifndef _TD_UTIL_SKILIST_H
+#define _TD_UTIL_SKILIST_H
#ifdef __cplusplus
extern "C" {
@@ -159,4 +159,4 @@ void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNod
}
#endif
-#endif // TDENGINE_TSKIPLIST_H
+#endif /*_TD_UTIL_SKILIST_H*/
diff --git a/include/util/tsocket.h b/include/util/tsocket.h
deleted file mode 100644
index b4f5516959..0000000000
--- a/include/util/tsocket.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#ifndef TDENGINE_TSOCKET_H
-#define TDENGINE_TSOCKET_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef WINDOWS
-#include "wepoll.h"
-#endif
-
-int32_t taosReadn(SOCKET sock, char *buffer, int32_t len);
-int32_t taosWriteMsg(SOCKET fd, void *ptr, int32_t nbytes);
-int32_t taosReadMsg(SOCKET fd, void *ptr, int32_t nbytes);
-int32_t taosNonblockwrite(SOCKET fd, char *ptr, int32_t nbytes);
-int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len);
-int32_t taosSetNonblocking(SOCKET sock, int32_t on);
-
-SOCKET taosOpenUdpSocket(uint32_t localIp, uint16_t localPort);
-SOCKET taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp);
-SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port);
-int32_t taosKeepTcpAlive(SOCKET sockFd);
-
-int32_t taosGetFqdn(char *);
-uint32_t taosGetIpv4FromFqdn(const char *);
-void tinet_ntoa(char *ipstr, uint32_t ip);
-uint32_t ip2uint(const char *const ip_addr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // TDENGINE_TSOCKET_H
diff --git a/include/util/tstrbuild.h b/include/util/tstrbuild.h
index 68d1914be3..48a302531c 100644
--- a/include/util/tstrbuild.h
+++ b/include/util/tstrbuild.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_STRING_BUILDER_H
-#define TDENGINE_STRING_BUILDER_H
+#ifndef _TD_UTIL_STRING_BUILDER_H
+#define _TD_UTIL_STRING_BUILDER_H
#include
#include
@@ -49,4 +49,4 @@ void taosStringBuilderAppendDouble(SStringBuilder* sb, double v);
}
#endif
-#endif
\ No newline at end of file
+#endif /*_TD_UTIL_STRING_BUILDER_H*/
\ No newline at end of file
diff --git a/include/util/tthread.h b/include/util/tthread.h
index 879c73ef89..0ff267dd1f 100644
--- a/include/util/tthread.h
+++ b/include/util/tthread.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TTHREAD_H
-#define TDENGINE_TTHREAD_H
+#ifndef _TD_UTIL_THREAD_H
+#define _TD_UTIL_THREAD_H
#ifdef __cplusplus
extern "C" {
@@ -34,4 +34,4 @@ bool taosThreadRunning(pthread_t* pthread);
}
#endif
-#endif // TDENGINE_TTHREAD_H
+#endif /*_TD_UTIL_THREAD_H*/
diff --git a/include/util/ttimer.h b/include/util/ttimer.h
index 6992f5ab6e..987d3f3cdc 100644
--- a/include/util/ttimer.h
+++ b/include/util/ttimer.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TTIMER_H
-#define TDENGINE_TTIMER_H
+#ifndef _TD_UTIL_TIMER_H
+#define _TD_UTIL_TIMER_H
#ifdef __cplusplus
extern "C" {
@@ -48,4 +48,4 @@ void taosUninitTimer();
}
#endif
-#endif // TDENGINE_TTIMER_H
+#endif /*_TD_UTIL_TIMER_H*/
diff --git a/include/util/tulog.h b/include/util/tulog.h
index 566da40a10..ba59f4eb79 100644
--- a/include/util/tulog.h
+++ b/include/util/tulog.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_COMMON_ULOG_H
-#define TDENGINE_COMMON_ULOG_H
+#ifndef _TD_UTIL_ULOG_H
+#define _TD_UTIL_ULOG_H
#ifdef __cplusplus
extern "C" {
@@ -39,4 +39,4 @@ extern int8_t tscEmbedded;
}
#endif
-#endif
+#endif /*_TD_UTIL_ULOG_H*/
diff --git a/include/util/tutil.h b/include/util/tutil.h
index ba48fcdc04..b599fc095c 100644
--- a/include/util/tutil.h
+++ b/include/util/tutil.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TUTIL_H
-#define TDENGINE_TUTIL_H
+#ifndef _TD_UTIL_UTIL_H
+#define _TD_UTIL_UTIL_H
#ifdef __cplusplus
extern "C" {
@@ -23,6 +23,7 @@ extern "C" {
#include "os.h"
#include "tmd5.h"
#include "tcrc32c.h"
+#include "tdef.h"
int32_t strdequote(char *src);
int32_t strRmquote(char *z, int32_t len);
@@ -45,16 +46,16 @@ int taosCheckVersion(char *input_client_version, char *input_server_version, in
char * taosIpStr(uint32_t ipInt);
uint32_t ip2uint(const char *const ip_addr);
-static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target, int32_t keylen) {
+static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
MD5_CTX context;
MD5Init(&context);
MD5Update(&context, inBuf, (unsigned int)inLen);
MD5Final(&context);
- memcpy(target, context.digest, keylen);
+ memcpy(target, context.digest, TSDB_KEY_LEN);
}
#ifdef __cplusplus
}
#endif
-#endif // TDENGINE_TUTIL_H
+#endif /*_TD_UTIL_UTIL_H*/
diff --git a/include/util/tworker.h b/include/util/tworker.h
index 7bc1eba2fd..156ced383e 100644
--- a/include/util/tworker.h
+++ b/include/util/tworker.h
@@ -13,30 +13,33 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TWORKER_H
-#define TDENGINE_TWORKER_H
+#ifndef _TD_UTIL_WORKER_H
+#define _TD_UTIL_WORKER_H
#ifdef __cplusplus
extern "C" {
#endif
-typedef void *(*FWorkerThread)(void *pWorker);
+typedef int32_t (*ProcessReqFp)(void *ahandle, void *msg);
+typedef void (*SendRspFp)(void *ahandle, void *msg, int32_t qtype, int32_t code);
+
struct SWorkerPool;
typedef struct {
- pthread_t thread; // thread
- int32_t id; // worker ID
- struct SWorkerPool *pPool;
+ pthread_t thread; // thread
+ int32_t id; // worker ID
+ struct SWorkerPool *pool;
} SWorker;
typedef struct SWorkerPool {
- int32_t max; // max number of workers
- int32_t min; // min number of workers
- int32_t num; // current number of workers
- void * qset;
- char * name;
- SWorker *worker;
- FWorkerThread workerFp;
+ int32_t max; // max number of workers
+ int32_t min; // min number of workers
+ int32_t num; // current number of workers
+ void * qset;
+ const char * name;
+ SWorker * workers;
+ ProcessReqFp reqFp;
+ SendRspFp rspFp;
pthread_mutex_t mutex;
} SWorkerPool;
@@ -49,4 +52,4 @@ void tWorkerFreeQueue(SWorkerPool *pPool, void *pQueue);
}
#endif
-#endif
+#endif /*_TD_UTIL_WORKER_H*/
diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c
index fbf8926fb4..1cebf99351 100644
--- a/source/common/src/tglobal.c
+++ b/source/common/src/tglobal.c
@@ -21,7 +21,6 @@
#include "tlog.h"
#include "tconfig.h"
#include "tglobal.h"
-#include "tsocket.h"
#include "tcompare.h"
#include "tutil.h"
#include "ttimezone.h"
@@ -385,25 +384,6 @@ static void taosCheckDataDirCfg() {
}
}
-static int32_t taosCheckTmpDir(void) {
-#if 0
- if (strlen(tsTempDir) <= 0){
- uError("tempDir is not set");
- return -1;
- }
-
- DIR *dir = opendir(tsTempDir);
- if (dir == NULL) {
- uError("can not open tempDir:%s, error:%s", tsTempDir, strerror(errno));
- return -1;
- }
-
- closedir(dir);
-#endif
- return 0;
-}
-
-
static void doInitGlobalConfig(void) {
osInit();
srand(taosSafeRand());
@@ -1700,7 +1680,7 @@ int32_t taosCheckGlobalCfg() {
taosCheckDataDirCfg();
- if (taosCheckTmpDir()) {
+ if (!taosDirExist(tsTempDir)) {
return -1;
}
diff --git a/source/libs/transport/src/rpcMain.c b/source/libs/transport/src/rpcMain.c
index 9bf2773dde..fe58ee2746 100644
--- a/source/libs/transport/src/rpcMain.c
+++ b/source/libs/transport/src/rpcMain.c
@@ -22,7 +22,6 @@
#include "lz4.h"
#include "tref.h"
#include "taoserror.h"
-#include "tsocket.h"
#include "tglobal.h"
#include "taosmsg.h"
#include "trpc.h"
diff --git a/source/libs/transport/src/rpcTcp.c b/source/libs/transport/src/rpcTcp.c
index 1f657a5b8d..d853fdb9f1 100644
--- a/source/libs/transport/src/rpcTcp.c
+++ b/source/libs/transport/src/rpcTcp.c
@@ -14,7 +14,6 @@
*/
#include "os.h"
-#include "tsocket.h"
#include "tutil.h"
#include "taosdef.h"
#include "taoserror.h"
diff --git a/source/libs/transport/src/rpcUdp.c b/source/libs/transport/src/rpcUdp.c
index 086a390cb8..5bc31c189a 100644
--- a/source/libs/transport/src/rpcUdp.c
+++ b/source/libs/transport/src/rpcUdp.c
@@ -14,7 +14,6 @@
*/
#include "os.h"
-#include "tsocket.h"
#include "ttimer.h"
#include "tutil.h"
#include "taosdef.h"
diff --git a/source/server/dnode/src/dnodeTelemetry.c b/source/server/dnode/src/dnodeTelemetry.c
index 466470c8c7..089a614590 100644
--- a/source/server/dnode/src/dnodeTelemetry.c
+++ b/source/server/dnode/src/dnodeTelemetry.c
@@ -17,7 +17,6 @@
#include "os.h"
#include "tbuffer.h"
#include "tglobal.h"
-#include "tsocket.h"
#include "dnodeCfg.h"
#include "dnodeTelemetry.h"
#include "mnode.h"
diff --git a/source/server/dnode/src/dnodeTrans.c b/source/server/dnode/src/dnodeTrans.c
index d9d2c9ad47..4d03338835 100644
--- a/source/server/dnode/src/dnodeTrans.c
+++ b/source/server/dnode/src/dnodeTrans.c
@@ -242,7 +242,7 @@ static void dnodeProcessMsgFromShell(DnTrans *trans, SRpcMsg *pMsg, SRpcEpSet *p
static int32_t dnodeAuthNetTest(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
if (strcmp(user, "nettestinternal") == 0) {
char pass[32] = {0};
- taosEncryptPass((uint8_t *)user, strlen(user), pass, TSDB_KEY_LEN);
+ taosEncryptPass((uint8_t *)user, strlen(user), pass);
*spi = 0;
*encrypt = 0;
*ckey = 0;
diff --git a/source/util/src/hash.c b/source/util/src/hash.c
index 2d48a7c3bf..644fc67eb5 100644
--- a/source/util/src/hash.c
+++ b/source/util/src/hash.c
@@ -16,6 +16,7 @@
#include "os.h"
#include "hash.h"
#include "tulog.h"
+#include "tdef.h"
#define EXT_SIZE 1024
diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c
index e31fbaaff1..29cd13a6d5 100644
--- a/source/util/src/tcompare.c
+++ b/source/util/src/tcompare.c
@@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
int32_t i = 0;
int32_t j = 0;
+ int32_t o = 0;
+ int32_t m = 0;
while ((c = patterStr[i++]) != 0) {
if (c == pInfo->matchAll) { /* Match "*" */
while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) {
- if (c == pInfo->matchOne && (j > size || str[j++] == 0)) {
- // empty string, return not match
- return TSDB_PATTERN_NOWILDCARDMATCH;
+ if (c == pInfo->matchOne) {
+ if (j > size || str[j++] == 0) {
+ // empty string, return not match
+ return TSDB_PATTERN_NOWILDCARDMATCH;
+ } else {
+ ++o;
+ }
}
}
@@ -249,9 +255,10 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
}
char next[3] = {toupper(c), tolower(c), 0};
+ m = o;
while (1) {
- size_t n = strcspn(str, next);
- str += n;
+ size_t n = strcspn(str + m, next);
+ str += m + n;
if (str[0] == 0 || (n >= size)) {
break;
@@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
if (ret != TSDB_PATTERN_NOMATCH) {
return ret;
}
+ m = 0;
}
return TSDB_PATTERN_NOWILDCARDMATCH;
}
c1 = str[j++];
-
+ ++o;
+
if (j <= size) {
if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; }
if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) {
@@ -292,7 +301,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
if (c == matchAll) { /* Match "%" */
while ((c = patterStr[i++]) == matchAll || c == matchOne) {
- if (c == matchOne && (j > size || str[j++] == 0)) {
+ if (c == matchOne && (j >= size || str[j++] == 0)) {
return TSDB_PATTERN_NOWILDCARDMATCH;
}
}
diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c
index b39e619ba2..b0256471cd 100644
--- a/source/util/src/tconfig.c
+++ b/source/util/src/tconfig.c
@@ -17,7 +17,6 @@
#include "os.h"
#include "tconfig.h"
#include "tulog.h"
-#include "tsocket.h"
#include "tutil.h"
SGlobalCfg tsGlobalConfig[TSDB_CFG_MAX_NUM] = {{0}};
diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c
index 0f81f59604..f134730c5c 100644
--- a/source/util/src/tlog.c
+++ b/source/util/src/tlog.c
@@ -154,7 +154,7 @@ static bool taosLockLogFile(int32_t fd) {
if (fd < 0) return false;
if (tsLogObj.fileNum > 1) {
- int32_t ret = taosUnLockFile(fd);
+ int32_t ret = taosLockFile(fd);
if (ret == 0) {
return true;
}
diff --git a/source/util/src/tlosertree.c b/source/util/src/tlosertree.c
index 7be2ca7461..c6e3a98493 100644
--- a/source/util/src/tlosertree.c
+++ b/source/util/src/tlosertree.c
@@ -15,7 +15,6 @@
#include "os.h"
#include "tlosertree.h"
-// #include "taosmsg.h"
#include "tulog.h"
// set initial value for loser tree
diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c
index d0a1fffa9e..4aac7b7abf 100644
--- a/source/util/src/ttimer.c
+++ b/source/util/src/ttimer.c
@@ -532,6 +532,9 @@ static void taosTmrModuleInit(void) {
}
void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) {
+ const char* ret = taosMonotonicInit();
+ tmrDebug("ttimer monotonic clock source:%s", ret);
+
pthread_once(&tmrModuleInit, taosTmrModuleInit);
pthread_mutex_lock(&tmrCtrlMutex);
diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c
index 8b4053bccd..3fe34755d7 100644
--- a/source/util/src/tworker.c
+++ b/source/util/src/tworker.c
@@ -19,78 +19,101 @@
#include "tqueue.h"
#include "tworker.h"
-int32_t tWorkerInit(SWorkerPool *pPool) {
- pPool->qset = taosOpenQset();
- pPool->worker = calloc(sizeof(SWorker), pPool->max);
- pthread_mutex_init(&pPool->mutex, NULL);
- for (int i = 0; i < pPool->max; ++i) {
- SWorker *pWorker = pPool->worker + i;
- pWorker->id = i;
- pWorker->pPool = pPool;
+static void *taosWorkerThreadFp(void *wparam) {
+ SWorker * worker = wparam;
+ SWorkerPool *pool = worker->pool;
+ void * msg = NULL;
+ int32_t qtype = 0;
+ void * ahandle = NULL;
+ int32_t code = 0;
+
+ setThreadName(pool->name);
+
+ while (1) {
+ if (taosReadQitemFromQset(pool->qset, &qtype, (void **)&msg, &ahandle) == 0) {
+ uDebug("pool:%s, worker:%d qset:%p, got no message and exiting", pool->name, worker->id, pool->qset);
+ break;
+ }
+
+ code = (*pool->reqFp)(ahandle, msg);
+ (*pool->rspFp)(ahandle, msg, qtype, code);
}
- uInfo("worker:%s is initialized, min:%d max:%d", pPool->name, pPool->min, pPool->max);
+ return NULL;
+}
+
+int32_t tWorkerInit(SWorkerPool *pool) {
+ pool->qset = taosOpenQset();
+ pool->workers = calloc(sizeof(SWorker), pool->max);
+ pthread_mutex_init(&pool->mutex, NULL);
+ for (int i = 0; i < pool->max; ++i) {
+ SWorker *pWorker = pool->workers + i;
+ pWorker->id = i;
+ pWorker->pool = pool;
+ }
+
+ uInfo("worker:%s is initialized, min:%d max:%d", pool->name, pool->min, pool->max);
return 0;
}
-void tWorkerCleanup(SWorkerPool *pPool) {
- for (int i = 0; i < pPool->max; ++i) {
- SWorker *pWorker = pPool->worker + i;
+void tWorkerCleanup(SWorkerPool *pool) {
+ for (int i = 0; i < pool->max; ++i) {
+ SWorker *pWorker = pool->workers + i;
if(taosCheckPthreadValid(pWorker->thread)) {
- taosQsetThreadResume(pPool->qset);
+ taosQsetThreadResume(pool->qset);
}
}
- for (int i = 0; i < pPool->max; ++i) {
- SWorker *pWorker = pPool->worker + i;
+ for (int i = 0; i < pool->max; ++i) {
+ SWorker *pWorker = pool->workers + i;
if (taosCheckPthreadValid(pWorker->thread)) {
pthread_join(pWorker->thread, NULL);
}
}
- free(pPool->worker);
- taosCloseQset(pPool->qset);
- pthread_mutex_destroy(&pPool->mutex);
+ free(pool->workers);
+ taosCloseQset(pool->qset);
+ pthread_mutex_destroy(&pool->mutex);
- uInfo("worker:%s is closed", pPool->name);
+ uInfo("worker:%s is closed", pool->name);
}
-void *tWorkerAllocQueue(SWorkerPool *pPool, void *ahandle) {
- pthread_mutex_lock(&pPool->mutex);
+void *tWorkerAllocQueue(SWorkerPool *pool, void *ahandle) {
+ pthread_mutex_lock(&pool->mutex);
taos_queue pQueue = taosOpenQueue();
if (pQueue == NULL) {
- pthread_mutex_unlock(&pPool->mutex);
+ pthread_mutex_unlock(&pool->mutex);
return NULL;
}
- taosAddIntoQset(pPool->qset, pQueue, ahandle);
+ taosAddIntoQset(pool->qset, pQueue, ahandle);
// spawn a thread to process queue
- if (pPool->num < pPool->max) {
+ if (pool->num < pool->max) {
do {
- SWorker *pWorker = pPool->worker + pPool->num;
+ SWorker *pWorker = pool->workers + pool->num;
pthread_attr_t thAttr;
pthread_attr_init(&thAttr);
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
- if (pthread_create(&pWorker->thread, &thAttr, pPool->workerFp, pWorker) != 0) {
- uError("worker:%s:%d failed to create thread to process since %s", pPool->name, pWorker->id, strerror(errno));
+ if (pthread_create(&pWorker->thread, &thAttr, taosWorkerThreadFp, pWorker) != 0) {
+ uError("workers:%s:%d failed to create thread to process since %s", pool->name, pWorker->id, strerror(errno));
}
pthread_attr_destroy(&thAttr);
- pPool->num++;
- uDebug("worker:%s:%d is launched, total:%d", pPool->name, pWorker->id, pPool->num);
- } while (pPool->num < pPool->min);
+ pool->num++;
+ uDebug("workers:%s:%d is launched, total:%d", pool->name, pWorker->id, pool->num);
+ } while (pool->num < pool->min);
}
- pthread_mutex_unlock(&pPool->mutex);
- uDebug("worker:%s, queue:%p is allocated, ahandle:%p", pPool->name, pQueue, ahandle);
+ pthread_mutex_unlock(&pool->mutex);
+ uDebug("workers:%s, queue:%p is allocated, ahandle:%p", pool->name, pQueue, ahandle);
return pQueue;
}
-void tWorkerFreeQueue(SWorkerPool *pPool, void *pQueue) {
+void tWorkerFreeQueue(SWorkerPool *pool, void *pQueue) {
taosCloseQueue(pQueue);
- uDebug("worker:%s, queue:%p is freed", pPool->name, pQueue);
+ uDebug("workers:%s, queue:%p is freed", pool->name, pQueue);
}