diff --git a/include/common/schema.h b/include/common/schema.h
index 2b19eca76c972dbff713444beeb15b9e763b30af..ccc91f09ffdeab8d8fd5f35aa3b915635fd9dd72 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 dd7dfd9518adf0381505a2d53a770e1dd5a3a54e..bae3dcf5e64485fc7c23127f0f14a66e1705ea7a 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 d59b88c7e698b3e965b5923efdc760e0289f7250..7e3060103753de7d45c7c09b67f91621324c5307 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 76743f10a4a4636748706f197f6777a8c9b1963e..be2f6907525f6324fb133d3ff3bcbd80ee5e4dc3 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 27e8871e2f7b32bf7772dfa0cbc9c3164a312f2d..e47cb5c1cb41c8ff763fd0b9efa6f1343b523fb8 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 918763ebb4b92399872f10c0dd632689eaa08d1b..e37996b9c7e441a9edfe7c6fcf5dd102bc5973c2 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 ab7baea2d71558a218fdedd3de4184a517272ee6..e348381ae0649cfd4d81a7de987ea11b3ccc9262 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 0ede2e1e6f71c69aa6aaed2c05d671840679ce5c..e28f8644ede5725f16772aab30326950a851c558 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 867d4ae2dddff7dd114aa72684a1bf5a83d0b465..ffabe0d935622bf6beffe9d94fc8c9e705a8857a 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 91ae3866226e65cc305b03338075380b3949dd96..d809c75d67983fb6ac844a656a361876ea7d3504 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 b29a535ec2c80f7fb058e3d1c55e5d16ed71c3c4..5809d09b15253d983f44b251ed2050fc588d3c22 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 c6e95d5d61d6fbd7782bfb11d1bf361165810586..be4b7af32a7d92d313b7fdec83a2bceb600ec827 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 0ae983dba054739bdd8521dfb2e1f6447205014c..cc50a29d57a2f1a308b8b236fc7bb80122adb387 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 f62329183f82a57bcf65d136aaec65d8babd5f71..552e52636fb1fcb3a394a68bdf33894e592471b7 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 9b0ad2cf13b6df01bda56906891a4de677ff08a3..5f9fe5134bb9b6ac7cb5c8996b26e7a7e86017a2 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 42296f80ba3199b463452513adf126a03945bd10..2150b818d7b514885c0b820b7406cce717ecf1d3 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 c69a662846e15d515136d51a95b39d488a282f5c..f95eb281cf8270cfc3152647936dd55453650a35 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 8db9c6584f71827c6f2bd89853a88a98112435ce..2b3678ac6785f2f41eded008a80dda62a9f93362 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 62b52827d68b33ac2ee84e884772dbf416e2ef64..688fb8f7ef0b31c3f99419c061015a697764e143 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 04c2d1fcf0546737a397ccb5499a7477e26c6465..3992d8b02e38c8bdd304d70a4b6d55954a891c2b 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 12ca3a54432187ea5af0ac24208e81d5028359bb..c1907b0c464c657ee2aeebba7871d1dd786e7d40 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 1125516d34c65da1b5d0c47dadd126aa0b1959fa..4b2c583b4baf0b338d5e7383a94703bd64df258b 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 68fa4128ae6a7ceccb877219d2d886bd42e346a7..bc56d21b3ac09e58aa9e427914d8513b7f3b6b08 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 b09f39fc327c743bd388e5f04769849257f6a75b..04a06d127514dc11fb4d2b1b987e996f7dcd0599 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 155c127eff065d8a9b83bf60e5e54ad3b5db1100..ff62c9e34131256b20419816e6cef7eda47008ab 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 70f54e921da3166645bd43f4e3fe58bc144fe714..c96f997f06c363bfb06b8177a50b801a0cfbaea7 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 e4439439ced6522e26c8db4a560c50f5b0cb8a16..1a977fd04c27b14b3ce0ce242b3d523e1d67d688 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 b71cdb286814dd7b2afe0b4e41cebef66efac3d9..197cfff958416dc49db20b59dc8a2b6fe3216200 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 a99085923e7e2316ab80aac9e08c4c02ef861aae..5c6e59b103f442a1d6e92c443f13575a9d432dda 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 58f2ca8c5c81408b35c2c9435357deeb2b0f13a4..d6ffde82ca0febcce8183f6d552d124de25119fc 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 d7fd038f37c9e1698394c90e07aaf9ac6a23590c..329f4acf1105433f31d2aea02767dc1c693f2b06 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 f2c6a0ef006cc77ba8a865994aaf5fb31d0c21a1..3e3db738a9f372082d785bedb28da776c23ba59f 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 7511b61f417c76b312faeb3da0855119658bdd68..e4f28d8cff8c0fd5c0333b2e8eced98fd1599998 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 c3051464e556860178be36f3473f5e4686f6082e..cd897435fabeaa050b77ae916c9f18d6eb2aea43 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 085c10c55198fc92bfacb0628c38f05da508bfb9..cc7d075f5209dfb3ab463a1c2cdb4ec39d0bbcf2 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 a1591512c1f87f524837a7986e3c8b3e14e25924..d60c0c5ad4aa7a7e3e314d53765347b5209c8b84 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 6f722533ac599d20450419f060160eb160d6d2a0..1e76b5198ab41f874c4d89f8831bd95a2c952273 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 9aa225078b4e4733e7aa0b5cc0dc30c2130981b7..8e991727a7de94b802674ccc90153585188f733b 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 b4f55169594589b83c299694723cb234bd21ed7d..0000000000000000000000000000000000000000
--- 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 68d1914be3c216a05a03fe6b80490ca1ee7bea4f..48a302531cf9c80cc9c8b4ceff3b4ba714127dd1 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 879c73ef89162a009dcf26d033f87858d7b08bf6..0ff267dd1fef8e2e52d5032d15441604110655c0 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 6992f5ab6ea792f6cdadd0af217fa5cb8b02dbc5..987d3f3cdc95f983b6d9bb54168da11aa5f8340a 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 566da40a10e078b9789e2e1b76a8d82fe89aef46..ba59f4eb791b449345295cb836af0ddc83094a55 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 ba48fcdc049fb26314366b2cf2e2db6e2f2f2831..b599fc095c5216bd81da85032fbeecc61aa76a2c 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 7bc1eba2fdcca0409737d9305911cd2987afe1ab..156ced383e0a9d81cbddd22c293853c81a41e88c 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 fbf8926fb47b3d50e2b9965487eab4a554253c04..1cebf9935124632c2c83dd66c5a6ab70628f5230 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 9bf2773dde6c26416e414b5d9b7df8d1db035f4e..fe58ee2746097d902784c9ff101b0ebb1556f57c 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 1f657a5b8d3c4c79aac451af6e0372f8fbb4387e..d853fdb9f13f855cafdc362b0caa36dce4fce2bb 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 086a390cb8ea2a95f576cb1bff81dfc79769863a..5bc31c189a0eef9dbd145e23aea5be4e0b9b0f1d 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 466470c8c7f4b034701f27ede39654169afc1cf6..089a61459029e2453386c111652a5816dc6b5c1a 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 d9d2c9ad47912fd1c1e5351c75b6ddbf03d2a324..4d0333883539183be5c092ece4fdba75b6e1600b 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 2d48a7c3bf1acf024b6a807c5fe3a55375c40417..644fc67eb5a3f34771ea74bc70ccc5525999d6f7 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 e31fbaaff1af6353417c96fe671628f2556b3924..29cd13a6d5effbde356d43f2521c976ce1222fa5 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 b39e619ba2305d0d2a678b081f62f1e155fa6377..b0256471cdfd6cb2afaa9fefa767ef6808c30580 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 0f81f596042c5b504f57e6e9687040ee8106ccec..f134730c5c2837be15af6a8e6d8cf506ffbb5998 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 7be2ca74613c44fcc4155f48b908cd45e6a37e3d..c6e3a984931ee75b99246c258631f7dbf8ded252 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 d0a1fffa9e4dd4f28f9a4169241a2e2d44874373..4aac7b7abf2e50626158514ac01969130b2fb637 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 8b4053bccd1ce8d9d3f58328d838f4ba5132a100..3fe34755d74913178c942fa805c09e6974dcc40c 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;
+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);
+ }
+
+ 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->pPool = pPool;
+ pWorker->pool = pool;
}
- uInfo("worker:%s is initialized, min:%d max:%d", pPool->name, pPool->min, pPool->max);
+ 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);
}