提交 d20aa8f8 编写于 作者: S Shengliang Guan

[TD-10430] check util and common files

上级 1c40f32e
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_SCHEMA_H_ #ifndef _TD_COMMON_SCHEMA_H_
#define _TD_SCHEMA_H_ #define _TD_COMMON_SCHEMA_H_
#include "os.h" #include "os.h"
...@@ -100,4 +100,4 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder); ...@@ -100,4 +100,4 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
} }
#endif #endif
#endif /*_TD_SCHEMA_H_*/ #endif /*_TD_COMMON_SCHEMA_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_COMMON_TAOS_DEF_H #ifndef _TD_COMMON_TAOS_DEF_H_
#define _TD_COMMON_TAOS_DEF_H #define _TD_COMMON_TAOS_DEF_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -76,4 +76,4 @@ extern char *qtypeStr[]; ...@@ -76,4 +76,4 @@ extern char *qtypeStr[];
} }
#endif #endif
#endif /*_TD_COMMON_TAOS_DEF_H*/ #endif /*_TD_COMMON_TAOS_DEF_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TAOSERROR_H #ifndef _TD_COMMON_TAOS_ERROR_H_
#define TDENGINE_TAOSERROR_H #define _TD_COMMON_TAOS_ERROR_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -463,4 +463,4 @@ int32_t* taosGetErrno(); ...@@ -463,4 +463,4 @@ int32_t* taosGetErrno();
} }
#endif #endif
#endif //TDENGINE_TAOSERROR_H #endif /*_TD_COMMON_TAOS_ERROR_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TAOSMSG_H #ifndef _TD_COMMON_TAOS_MSG_H_
#define TDENGINE_TAOSMSG_H #define _TD_COMMON_TAOS_MSG_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -961,4 +961,4 @@ typedef struct { ...@@ -961,4 +961,4 @@ typedef struct {
} }
#endif #endif
#endif #endif /*_TD_COMMON_TAOS_MSG_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_QARITHMETICOPERATOR_H #ifndef _TD_COMMON_QARITHMETICOPERATOR_H_
#define TDENGINE_QARITHMETICOPERATOR_H #define _TD_COMMON_QARITHMETICOPERATOR_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -29,4 +29,4 @@ _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr); ...@@ -29,4 +29,4 @@ _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr);
} }
#endif #endif
#endif // TDENGINE_TSYNTAXTREEFUNCTION_H #endif /*_TD_COMMON_QARITHMETICOPERATOR_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TSQLMSGTYPE_H #ifndef _TD_COMMON_SQLMSGTYPE_H_
#define TDENGINE_TSQLMSGTYPE_H #define _TD_COMMON_SQLMSGTYPE_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -116,4 +116,4 @@ extern char *sqlCmd[]; ...@@ -116,4 +116,4 @@ extern char *sqlCmd[];
} }
#endif #endif
#endif // TDENGINE_TSQLMSGTYPE_H #endif /*_TD_COMMON_SQLMSGTYPE_H_*/
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_DATA_FORMAT_H_ #ifndef _TD_COMMON_DATA_FORMAT_H_
#define _TD_DATA_FORMAT_H_ #define _TD_COMMON_DATA_FORMAT_H_
#include "os.h" #include "os.h"
#include "talgo.h" #include "talgo.h"
...@@ -813,4 +813,4 @@ static FORCE_INLINE char *payloadNextCol(char *pCol) { return (char *)POINTER_SH ...@@ -813,4 +813,4 @@ static FORCE_INLINE char *payloadNextCol(char *pCol) { return (char *)POINTER_SH
} }
#endif #endif
#endif // _TD_DATA_FORMAT_H_ #endif /*_TD_COMMON_DATA_FORMAT_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TEXPR_H #ifndef _TD_COMMON_EXPR_H_
#define TDENGINE_TEXPR_H #define _TD_COMMON_EXPR_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -104,4 +104,4 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len); ...@@ -104,4 +104,4 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len);
} }
#endif #endif
#endif // TDENGINE_TEXPR_H #endif /*_TD_COMMON_EXPR_H_*/
...@@ -13,13 +13,15 @@ ...@@ -13,13 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_COMMON_GLOBAL_H #ifndef _TD_COMMON_GLOBAL_H_
#define _TD_COMMON_GLOBAL_H #define _TD_COMMON_GLOBAL_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "tdef.h"
// cluster // cluster
extern char tsFirst[]; extern char tsFirst[];
extern char tsSecond[]; extern char tsSecond[];
...@@ -186,7 +188,7 @@ extern char Compressor[]; ...@@ -186,7 +188,7 @@ extern char Compressor[];
extern int8_t tsDeadLockKillQuery; extern int8_t tsDeadLockKillQuery;
typedef struct { typedef struct {
char dir[128]; char dir[TSDB_FILENAME_LEN];
int level; int level;
int primary; int primary;
} SDiskCfg; } SDiskCfg;
...@@ -208,4 +210,4 @@ void taosPrintDataDirCfg(); ...@@ -208,4 +210,4 @@ void taosPrintDataDirCfg();
} }
#endif #endif
#endif #endif /*_TD_COMMON_GLOBAL_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_COMMON_LOCALE_H #ifndef _TD_COMMON_LOCALE_H_
#define TDENGINE_COMMON_LOCALE_H #define _TD_COMMON_LOCALE_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -24,6 +24,6 @@ void tsSetLocale(); ...@@ -24,6 +24,6 @@ void tsSetLocale();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif /*_TD_COMMON_LOCALE_H_*/
#endif #endif
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_NAME_H #ifndef _TD_COMMON_NAME_H_
#define TDENGINE_NAME_H #define _TD_COMMON_NAME_H_
#include "os.h" #include "os.h"
#include "taosmsg.h" #include "taosmsg.h"
...@@ -136,4 +136,4 @@ int32_t tNameSetAcctId(SName* dst, const char* acct); ...@@ -136,4 +136,4 @@ int32_t tNameSetAcctId(SName* dst, const char* acct);
int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken); int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken);
#endif // TDENGINE_NAME_H #endif /*_TD_COMMON_NAME_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TROW_H_ #ifndef _TD_COMMON_ROW_H_
#define _TD_TROW_H_ #define _TD_COMMON_ROW_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -24,4 +24,4 @@ extern "C" { ...@@ -24,4 +24,4 @@ extern "C" {
} }
#endif #endif
#endif /*_TD_TROW_H_*/ #endif /*_TD_COMMON_ROW_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_COMMON_TIMEZONE_H #ifndef _TD_COMMON_TIMEZONE_H_
#define TDENGINE_COMMON_TIMEZONE_H #define _TD_COMMON_TIMEZONE_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -26,4 +26,4 @@ void tsSetTimeZone(); ...@@ -26,4 +26,4 @@ void tsSetTimeZone();
} }
#endif #endif
#endif #endif /*_TD_COMMON_TIMEZONE_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TTOKEN_H #ifndef _TD_COMMON_TOKEN_H_
#define TDENGINE_TTOKEN_H #define _TD_COMMON_TOKEN_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -189,4 +189,4 @@ SStrToken taosTokenDup(SStrToken* pToken, char* buf, int32_t len); ...@@ -189,4 +189,4 @@ SStrToken taosTokenDup(SStrToken* pToken, char* buf, int32_t len);
} }
#endif #endif
#endif // TDENGINE_TTOKEN_H #endif /*_TD_COMMON_TOKEN_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TTOKENDEF_H #ifndef _TD_COMMON_TOKEN_DEF_H_
#define TDENGINE_TTOKENDEF_H #define _TD_COMMON_TOKEN_DEF_H_
#define TK_ID 1 #define TK_ID 1
#define TK_BOOL 2 #define TK_BOOL 2
...@@ -223,6 +223,6 @@ ...@@ -223,6 +223,6 @@
#define TK_FILE 306 #define TK_FILE 306
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query #define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
#endif #endif /*_TD_COMMON_TOKEN_DEF_H_*/
#ifndef TDENGINE_TTYPE_H #ifndef _TD_COMMON_TYPE_H_
#define TDENGINE_TTYPE_H #define _TD_COMMON_TYPE_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -178,4 +178,4 @@ int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bo ...@@ -178,4 +178,4 @@ int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bo
} }
#endif #endif
#endif // TDENGINE_TTYPE_H #endif /*_TD_COMMON_TYPE_H_*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TVARIANT_H #ifndef _TD_COMMON_VARIANT_H_
#define TDENGINE_TVARIANT_H #define _TD_COMMON_VARIANT_H_
#include "tarray.h" #include "tarray.h"
#include "ttoken.h" #include "ttoken.h"
...@@ -61,4 +61,4 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type); ...@@ -61,4 +61,4 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type);
} }
#endif #endif
#endif // TDENGINE_TVARIANT_H #endif /*_TD_COMMON_VARIANT_H_*/
...@@ -102,15 +102,6 @@ extern "C" { ...@@ -102,15 +102,6 @@ extern "C" {
#define UNUSED_FUNC #define UNUSED_FUNC
#endif #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 #ifdef tListLen
#undefine tListLen #undefine tListLen
#endif #endif
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
extern "C" { extern "C" {
#endif #endif
#define TSDB_LOCALE_LEN 64 #define TSDB_LOCALE_LEN 64
#define TSDB_TIMEZONE_LEN 96 #define TSDB_TIMEZONE_LEN 96
extern int64_t tsPageSize; extern int64_t tsPageSize;
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_UTIL_HASH_FUNC_H #ifndef _TD_UTIL_HASHFUNC_H
#define _TD_UTIL_HASH_FUNC_H #define _TD_UTIL_HASHFUNC_H
#include "os.h" #include "os.h"
...@@ -48,4 +48,4 @@ _hash_fn_t taosGetDefaultHashFunction(int32_t type); ...@@ -48,4 +48,4 @@ _hash_fn_t taosGetDefaultHashFunction(int32_t type);
_equal_fn_t taosGetDefaultEqualFunction(int32_t type); _equal_fn_t taosGetDefaultEqualFunction(int32_t type);
#endif /*_TD_UTIL_HASH_FUNC_H*/ #endif /*_TD_UTIL_HASHFUNC_H*/
...@@ -13,22 +13,14 @@ ...@@ -13,22 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TCHECKSUM_H #ifndef _TD_UTIL_CHECKSUM_H
#define TDENGINE_TCHECKSUM_H #define _TD_UTIL_CHECKSUM_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <assert.h> #include "os.h"
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "tcrc32c.h" #include "tcrc32c.h"
#include "tutil.h" #include "tutil.h"
...@@ -64,4 +56,4 @@ static FORCE_INLINE int taosCheckChecksumWhole(const uint8_t *stream, uint32_t s ...@@ -64,4 +56,4 @@ static FORCE_INLINE int taosCheckChecksumWhole(const uint8_t *stream, uint32_t s
} }
#endif #endif
#endif // TDENGINE_TCHECKSUM_H #endif /*_TD_UTIL_CHECKSUM_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TCOMPARE_H #ifndef _TD_UTIL_COMPARE_H
#define TDENGINE_TCOMPARE_H #define _TD_UTIL_COMPARE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -93,4 +93,4 @@ int32_t compareWStrPatternComp(const void* pLeft, const void* pRight); ...@@ -93,4 +93,4 @@ int32_t compareWStrPatternComp(const void* pLeft, const void* pRight);
} }
#endif #endif
#endif // TDENGINE_TCOMPARE_H #endif /*_TD_UTIL_COMPARE_H*/
...@@ -87,8 +87,8 @@ bool taosReadGlobalCfg(); ...@@ -87,8 +87,8 @@ bool taosReadGlobalCfg();
void taosPrintGlobalCfg(); void taosPrintGlobalCfg();
void taosDumpGlobalCfg(); void taosDumpGlobalCfg();
void taosInitConfigOption(SGlobalCfg cfg); void taosInitConfigOption(SGlobalCfg cfg);
SGlobalCfg * taosGetConfigOption(const char *option); SGlobalCfg *taosGetConfigOption(const char *option);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -33,6 +33,15 @@ extern "C" { ...@@ -33,6 +33,15 @@ extern "C" {
// Bytes for each type. // Bytes for each type.
extern const int32_t TYPE_BYTES[15]; 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) #define TSDB_KEYSIZE sizeof(TSKEY)
#if LINUX #if LINUX
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TFILE_H #ifndef _TD_UTIL_FILE_H
#define TDENGINE_TFILE_H #define _TD_UTIL_FILE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -44,4 +44,4 @@ int32_t tfFtruncate(int64_t tfd, int64_t length); ...@@ -44,4 +44,4 @@ int32_t tfFtruncate(int64_t tfd, int64_t length);
} }
#endif #endif
#endif // TDENGINE_TFILE_H #endif /*_TD_UTIL_FILE_H*/
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TD_TFUNCTIONAL_H #ifndef _TD_UTIL_FUNCTIONAL_H
#define TD_TFUNCTIONAL_H #define _TD_UTIL_FUNCTIONAL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -53,4 +53,4 @@ void voidInvoke(tVoidSavedFunc* const pSavedFunc); ...@@ -53,4 +53,4 @@ void voidInvoke(tVoidSavedFunc* const pSavedFunc);
} }
#endif #endif
#endif #endif /*_TD_UTIL_FUNCTIONAL_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TIDPOOL_H #ifndef _TD_UTIL_IDPOOL_H
#define TDENGINE_TIDPOOL_H #define _TD_UTIL_IDPOOL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -40,4 +40,4 @@ bool taosIdPoolMarkStatus(void *handle, int id); ...@@ -40,4 +40,4 @@ bool taosIdPoolMarkStatus(void *handle, int id);
} }
#endif #endif
#endif #endif /*_TD_UTIL_IDPOOL_H*/
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TKEY_H #ifndef _TD_UTIL_KEY_H
#define TDENGINE_TKEY_H #define _TD_UTIL_KEY_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -28,4 +28,4 @@ char * taosDesDecode(int64_t key, char *src, int len); ...@@ -28,4 +28,4 @@ char * taosDesDecode(int64_t key, char *src, int len);
} }
#endif #endif
#endif #endif /*_TD_UTIL_KEY_H*/
\ No newline at end of file \ No newline at end of file
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
extern "C" { extern "C" {
#endif #endif
// log // log
extern int8_t tsAsyncLog; extern int8_t tsAsyncLog;
extern int32_t tsNumOfLogLines; extern int32_t tsNumOfLogLines;
......
...@@ -13,15 +13,13 @@ ...@@ -13,15 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TLOSERTREE_H #ifndef _TD_UTIL_LOSERTREE_H
#define TDENGINE_TLOSERTREE_H #define _TD_UTIL_LOSERTREE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <stdint.h>
typedef int (*__merge_compare_fn_t)(const void *, const void *, void *param); typedef int (*__merge_compare_fn_t)(const void *, const void *, void *param);
typedef struct SLoserTreeNode { typedef struct SLoserTreeNode {
...@@ -51,4 +49,4 @@ void tLoserTreeDisplay(SLoserTreeInfo *pTree); ...@@ -51,4 +49,4 @@ void tLoserTreeDisplay(SLoserTreeInfo *pTree);
} }
#endif #endif
#endif // TDENGINE_TLOSERTREE_H #endif /*_TD_UTIL_LOSERTREE_H*/
...@@ -22,10 +22,8 @@ ...@@ -22,10 +22,8 @@
*********************************************************************** ***********************************************************************
*/ */
#ifndef _taos_md5_header_ #ifndef _TD_UTIL_MD5_H
#define _taos_md5_header_ #define _TD_UTIL_MD5_H
#include <stdint.h>
typedef struct { typedef struct {
uint32_t i[2]; /* number of _bits_ handled mod 2^64 */ uint32_t i[2]; /* number of _bits_ handled mod 2^64 */
...@@ -38,4 +36,4 @@ void MD5Init(MD5_CTX *mdContext); ...@@ -38,4 +36,4 @@ void MD5Init(MD5_CTX *mdContext);
void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen);
void MD5Final(MD5_CTX *mdContext); void MD5Final(MD5_CTX *mdContext);
#endif #endif /*_TD_UTIL_MD5_H*/
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TMEMPOOL_H #ifndef _TD_UTIL_MEMPOOL_H
#define TDENGINE_TMEMPOOL_H #define _TD_UTIL_MEMPOOL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -33,4 +33,4 @@ void taosMemPoolCleanUp(mpool_h handle); ...@@ -33,4 +33,4 @@ void taosMemPoolCleanUp(mpool_h handle);
} }
#endif #endif
#endif #endif /*_TD_UTIL_MEMPOOL_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TNOTE_H #ifndef _TD_UTIL_NOTE_H
#define TDENGINE_TNOTE_H #define _TD_UTIL_NOTE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -61,4 +61,4 @@ void taosNotePrintBuffer(SNoteObj *pNote, char *buffer, int32_t len); ...@@ -61,4 +61,4 @@ void taosNotePrintBuffer(SNoteObj *pNote, char *buffer, int32_t len);
} }
#endif #endif
#endif #endif /*_TD_UTIL_NOTE_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TAOS_QUEUE_H #ifndef _TD_UTIL_QUEUE_H
#define TAOS_QUEUE_H #define _TD_UTIL_QUEUE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -71,6 +71,6 @@ int taosGetQsetItemsNumber(taos_qset param); ...@@ -71,6 +71,6 @@ int taosGetQsetItemsNumber(taos_qset param);
} }
#endif #endif
#endif #endif /*_TD_UTIL_QUEUE_H*/
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TREF_H #ifndef _TD_UTIL_REF_H
#define TDENGINE_TREF_H #define _TD_UTIL_REF_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -74,4 +74,4 @@ void demoIterateRefs(int rsetId) { ...@@ -74,4 +74,4 @@ void demoIterateRefs(int rsetId) {
} }
#endif #endif
#endif // TDENGINE_TREF_H #endif /*_TD_UTIL_REF_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TSCHED_H #ifndef _TD_UTIL_SCHED_H
#define TDENGINE_TSCHED_H #define _TD_UTIL_SCHED_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -68,4 +68,4 @@ void taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg); ...@@ -68,4 +68,4 @@ void taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg);
} }
#endif #endif
#endif // TDENGINE_TSCHED_H #endif /*_TD_UTIL_SCHED_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TSCOMPRESSION_H #ifndef _TD_UTIL_COMPRESSION_H
#define TDENGINE_TSCOMPRESSION_H #define _TD_UTIL_COMPRESSION_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -366,4 +366,4 @@ static FORCE_INLINE int tsDecompressTimestamp(const char *const input, int compr ...@@ -366,4 +366,4 @@ static FORCE_INLINE int tsDecompressTimestamp(const char *const input, int compr
} }
#endif #endif
#endif // TDENGINE_TSCOMPRESSION_H #endif /*_TD_UTIL_COMPRESSION_H*/
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TSKIPLIST_H #ifndef _TD_UTIL_SKILIST_H
#define TDENGINE_TSKIPLIST_H #define _TD_UTIL_SKILIST_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -159,4 +159,4 @@ void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNod ...@@ -159,4 +159,4 @@ void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNod
} }
#endif #endif
#endif // TDENGINE_TSKIPLIST_H #endif /*_TD_UTIL_SKILIST_H*/
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_STRING_BUILDER_H #ifndef _TD_UTIL_STRING_BUILDER_H
#define TDENGINE_STRING_BUILDER_H #define _TD_UTIL_STRING_BUILDER_H
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
...@@ -49,4 +49,4 @@ void taosStringBuilderAppendDouble(SStringBuilder* sb, double v); ...@@ -49,4 +49,4 @@ void taosStringBuilderAppendDouble(SStringBuilder* sb, double v);
} }
#endif #endif
#endif #endif /*_TD_UTIL_STRING_BUILDER_H*/
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TTHREAD_H #ifndef _TD_UTIL_THREAD_H
#define TDENGINE_TTHREAD_H #define _TD_UTIL_THREAD_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -34,4 +34,4 @@ bool taosThreadRunning(pthread_t* pthread); ...@@ -34,4 +34,4 @@ bool taosThreadRunning(pthread_t* pthread);
} }
#endif #endif
#endif // TDENGINE_TTHREAD_H #endif /*_TD_UTIL_THREAD_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TTIMER_H #ifndef _TD_UTIL_TIMER_H
#define TDENGINE_TTIMER_H #define _TD_UTIL_TIMER_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -48,4 +48,4 @@ void taosUninitTimer(); ...@@ -48,4 +48,4 @@ void taosUninitTimer();
} }
#endif #endif
#endif // TDENGINE_TTIMER_H #endif /*_TD_UTIL_TIMER_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_COMMON_ULOG_H #ifndef _TD_UTIL_ULOG_H
#define TDENGINE_COMMON_ULOG_H #define _TD_UTIL_ULOG_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -39,4 +39,4 @@ extern int8_t tscEmbedded; ...@@ -39,4 +39,4 @@ extern int8_t tscEmbedded;
} }
#endif #endif
#endif #endif /*_TD_UTIL_ULOG_H*/
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TUTIL_H #ifndef _TD_UTIL_UTIL_H
#define TDENGINE_TUTIL_H #define _TD_UTIL_UTIL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -23,6 +23,7 @@ extern "C" { ...@@ -23,6 +23,7 @@ extern "C" {
#include "os.h" #include "os.h"
#include "tmd5.h" #include "tmd5.h"
#include "tcrc32c.h" #include "tcrc32c.h"
#include "tdef.h"
int32_t strdequote(char *src); int32_t strdequote(char *src);
int32_t strRmquote(char *z, int32_t len); int32_t strRmquote(char *z, int32_t len);
...@@ -45,16 +46,16 @@ int taosCheckVersion(char *input_client_version, char *input_server_version, in ...@@ -45,16 +46,16 @@ int taosCheckVersion(char *input_client_version, char *input_server_version, in
char * taosIpStr(uint32_t ipInt); char * taosIpStr(uint32_t ipInt);
uint32_t ip2uint(const char *const ip_addr); 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; MD5_CTX context;
MD5Init(&context); MD5Init(&context);
MD5Update(&context, inBuf, (unsigned int)inLen); MD5Update(&context, inBuf, (unsigned int)inLen);
MD5Final(&context); MD5Final(&context);
memcpy(target, context.digest, keylen); memcpy(target, context.digest, TSDB_KEY_LEN);
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // TDENGINE_TUTIL_H #endif /*_TD_UTIL_UTIL_H*/
...@@ -13,30 +13,33 @@ ...@@ -13,30 +13,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TWORKER_H #ifndef _TD_UTIL_WORKER_H
#define TDENGINE_TWORKER_H #define _TD_UTIL_WORKER_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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; struct SWorkerPool;
typedef struct { typedef struct {
pthread_t thread; // thread pthread_t thread; // thread
int32_t id; // worker ID int32_t id; // worker ID
struct SWorkerPool *pPool; struct SWorkerPool *pool;
} SWorker; } SWorker;
typedef struct SWorkerPool { typedef struct SWorkerPool {
int32_t max; // max number of workers int32_t max; // max number of workers
int32_t min; // min number of workers int32_t min; // min number of workers
int32_t num; // current number of workers int32_t num; // current number of workers
void * qset; void * qset;
char * name; const char * name;
SWorker *worker; SWorker * workers;
FWorkerThread workerFp; ProcessReqFp reqFp;
SendRspFp rspFp;
pthread_mutex_t mutex; pthread_mutex_t mutex;
} SWorkerPool; } SWorkerPool;
...@@ -49,4 +52,4 @@ void tWorkerFreeQueue(SWorkerPool *pPool, void *pQueue); ...@@ -49,4 +52,4 @@ void tWorkerFreeQueue(SWorkerPool *pPool, void *pQueue);
} }
#endif #endif
#endif #endif /*_TD_UTIL_WORKER_H*/
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "tlog.h" #include "tlog.h"
#include "tconfig.h" #include "tconfig.h"
#include "tglobal.h" #include "tglobal.h"
#include "tsocket.h"
#include "tcompare.h" #include "tcompare.h"
#include "tutil.h" #include "tutil.h"
#include "ttimezone.h" #include "ttimezone.h"
...@@ -385,25 +384,6 @@ static void taosCheckDataDirCfg() { ...@@ -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) { static void doInitGlobalConfig(void) {
osInit(); osInit();
srand(taosSafeRand()); srand(taosSafeRand());
...@@ -1700,7 +1680,7 @@ int32_t taosCheckGlobalCfg() { ...@@ -1700,7 +1680,7 @@ int32_t taosCheckGlobalCfg() {
taosCheckDataDirCfg(); taosCheckDataDirCfg();
if (taosCheckTmpDir()) { if (!taosDirExist(tsTempDir)) {
return -1; return -1;
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "lz4.h" #include "lz4.h"
#include "tref.h" #include "tref.h"
#include "taoserror.h" #include "taoserror.h"
#include "tsocket.h"
#include "tglobal.h" #include "tglobal.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "trpc.h" #include "trpc.h"
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include "os.h" #include "os.h"
#include "tsocket.h"
#include "tutil.h" #include "tutil.h"
#include "taosdef.h" #include "taosdef.h"
#include "taoserror.h" #include "taoserror.h"
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include "os.h" #include "os.h"
#include "tsocket.h"
#include "ttimer.h" #include "ttimer.h"
#include "tutil.h" #include "tutil.h"
#include "taosdef.h" #include "taosdef.h"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "os.h" #include "os.h"
#include "tbuffer.h" #include "tbuffer.h"
#include "tglobal.h" #include "tglobal.h"
#include "tsocket.h"
#include "dnodeCfg.h" #include "dnodeCfg.h"
#include "dnodeTelemetry.h" #include "dnodeTelemetry.h"
#include "mnode.h" #include "mnode.h"
......
...@@ -242,7 +242,7 @@ static void dnodeProcessMsgFromShell(DnTrans *trans, SRpcMsg *pMsg, SRpcEpSet *p ...@@ -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) { static int32_t dnodeAuthNetTest(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
if (strcmp(user, "nettestinternal") == 0) { if (strcmp(user, "nettestinternal") == 0) {
char pass[32] = {0}; char pass[32] = {0};
taosEncryptPass((uint8_t *)user, strlen(user), pass, TSDB_KEY_LEN); taosEncryptPass((uint8_t *)user, strlen(user), pass);
*spi = 0; *spi = 0;
*encrypt = 0; *encrypt = 0;
*ckey = 0; *ckey = 0;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "os.h" #include "os.h"
#include "hash.h" #include "hash.h"
#include "tulog.h" #include "tulog.h"
#include "tdef.h"
#define EXT_SIZE 1024 #define EXT_SIZE 1024
......
...@@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
int32_t i = 0; int32_t i = 0;
int32_t j = 0; int32_t j = 0;
int32_t o = 0;
int32_t m = 0;
while ((c = patterStr[i++]) != 0) { while ((c = patterStr[i++]) != 0) {
if (c == pInfo->matchAll) { /* Match "*" */ if (c == pInfo->matchAll) { /* Match "*" */
while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) { while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) {
if (c == pInfo->matchOne && (j > size || str[j++] == 0)) { if (c == pInfo->matchOne) {
// empty string, return not match if (j > size || str[j++] == 0) {
return TSDB_PATTERN_NOWILDCARDMATCH; // 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 ...@@ -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}; char next[3] = {toupper(c), tolower(c), 0};
m = o;
while (1) { while (1) {
size_t n = strcspn(str, next); size_t n = strcspn(str + m, next);
str += n; str += m + n;
if (str[0] == 0 || (n >= size)) { if (str[0] == 0 || (n >= size)) {
break; break;
...@@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
if (ret != TSDB_PATTERN_NOMATCH) { if (ret != TSDB_PATTERN_NOMATCH) {
return ret; return ret;
} }
m = 0;
} }
return TSDB_PATTERN_NOWILDCARDMATCH; return TSDB_PATTERN_NOWILDCARDMATCH;
} }
c1 = str[j++]; c1 = str[j++];
++o;
if (j <= size) { if (j <= size) {
if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; } if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; }
if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) { 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 ...@@ -292,7 +301,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
if (c == matchAll) { /* Match "%" */ if (c == matchAll) { /* Match "%" */
while ((c = patterStr[i++]) == matchAll || c == matchOne) { 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; return TSDB_PATTERN_NOWILDCARDMATCH;
} }
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "os.h" #include "os.h"
#include "tconfig.h" #include "tconfig.h"
#include "tulog.h" #include "tulog.h"
#include "tsocket.h"
#include "tutil.h" #include "tutil.h"
SGlobalCfg tsGlobalConfig[TSDB_CFG_MAX_NUM] = {{0}}; SGlobalCfg tsGlobalConfig[TSDB_CFG_MAX_NUM] = {{0}};
......
...@@ -154,7 +154,7 @@ static bool taosLockLogFile(int32_t fd) { ...@@ -154,7 +154,7 @@ static bool taosLockLogFile(int32_t fd) {
if (fd < 0) return false; if (fd < 0) return false;
if (tsLogObj.fileNum > 1) { if (tsLogObj.fileNum > 1) {
int32_t ret = taosUnLockFile(fd); int32_t ret = taosLockFile(fd);
if (ret == 0) { if (ret == 0) {
return true; return true;
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "os.h" #include "os.h"
#include "tlosertree.h" #include "tlosertree.h"
// #include "taosmsg.h"
#include "tulog.h" #include "tulog.h"
// set initial value for loser tree // set initial value for loser tree
......
...@@ -532,6 +532,9 @@ static void taosTmrModuleInit(void) { ...@@ -532,6 +532,9 @@ static void taosTmrModuleInit(void) {
} }
void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) { 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_once(&tmrModuleInit, taosTmrModuleInit);
pthread_mutex_lock(&tmrCtrlMutex); pthread_mutex_lock(&tmrCtrlMutex);
......
...@@ -19,78 +19,101 @@ ...@@ -19,78 +19,101 @@
#include "tqueue.h" #include "tqueue.h"
#include "tworker.h" #include "tworker.h"
int32_t tWorkerInit(SWorkerPool *pPool) { static void *taosWorkerThreadFp(void *wparam) {
pPool->qset = taosOpenQset(); SWorker * worker = wparam;
pPool->worker = calloc(sizeof(SWorker), pPool->max); SWorkerPool *pool = worker->pool;
pthread_mutex_init(&pPool->mutex, NULL); void * msg = NULL;
for (int i = 0; i < pPool->max; ++i) { int32_t qtype = 0;
SWorker *pWorker = pPool->worker + i; 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->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; return 0;
} }
void tWorkerCleanup(SWorkerPool *pPool) { void tWorkerCleanup(SWorkerPool *pool) {
for (int i = 0; i < pPool->max; ++i) { for (int i = 0; i < pool->max; ++i) {
SWorker *pWorker = pPool->worker + i; SWorker *pWorker = pool->workers + i;
if(taosCheckPthreadValid(pWorker->thread)) { if(taosCheckPthreadValid(pWorker->thread)) {
taosQsetThreadResume(pPool->qset); taosQsetThreadResume(pool->qset);
} }
} }
for (int i = 0; i < pPool->max; ++i) { for (int i = 0; i < pool->max; ++i) {
SWorker *pWorker = pPool->worker + i; SWorker *pWorker = pool->workers + i;
if (taosCheckPthreadValid(pWorker->thread)) { if (taosCheckPthreadValid(pWorker->thread)) {
pthread_join(pWorker->thread, NULL); pthread_join(pWorker->thread, NULL);
} }
} }
free(pPool->worker); free(pool->workers);
taosCloseQset(pPool->qset); taosCloseQset(pool->qset);
pthread_mutex_destroy(&pPool->mutex); 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) { void *tWorkerAllocQueue(SWorkerPool *pool, void *ahandle) {
pthread_mutex_lock(&pPool->mutex); pthread_mutex_lock(&pool->mutex);
taos_queue pQueue = taosOpenQueue(); taos_queue pQueue = taosOpenQueue();
if (pQueue == NULL) { if (pQueue == NULL) {
pthread_mutex_unlock(&pPool->mutex); pthread_mutex_unlock(&pool->mutex);
return NULL; return NULL;
} }
taosAddIntoQset(pPool->qset, pQueue, ahandle); taosAddIntoQset(pool->qset, pQueue, ahandle);
// spawn a thread to process queue // spawn a thread to process queue
if (pPool->num < pPool->max) { if (pool->num < pool->max) {
do { do {
SWorker *pWorker = pPool->worker + pPool->num; SWorker *pWorker = pool->workers + pool->num;
pthread_attr_t thAttr; pthread_attr_t thAttr;
pthread_attr_init(&thAttr); pthread_attr_init(&thAttr);
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE); pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
if (pthread_create(&pWorker->thread, &thAttr, pPool->workerFp, pWorker) != 0) { if (pthread_create(&pWorker->thread, &thAttr, taosWorkerThreadFp, pWorker) != 0) {
uError("worker:%s:%d failed to create thread to process since %s", pPool->name, pWorker->id, strerror(errno)); uError("workers:%s:%d failed to create thread to process since %s", pool->name, pWorker->id, strerror(errno));
} }
pthread_attr_destroy(&thAttr); pthread_attr_destroy(&thAttr);
pPool->num++; pool->num++;
uDebug("worker:%s:%d is launched, total:%d", pPool->name, pWorker->id, pPool->num); uDebug("workers:%s:%d is launched, total:%d", pool->name, pWorker->id, pool->num);
} while (pPool->num < pPool->min); } while (pool->num < pool->min);
} }
pthread_mutex_unlock(&pPool->mutex); pthread_mutex_unlock(&pool->mutex);
uDebug("worker:%s, queue:%p is allocated, ahandle:%p", pPool->name, pQueue, ahandle); uDebug("workers:%s, queue:%p is allocated, ahandle:%p", pool->name, pQueue, ahandle);
return pQueue; return pQueue;
} }
void tWorkerFreeQueue(SWorkerPool *pPool, void *pQueue) { void tWorkerFreeQueue(SWorkerPool *pool, void *pQueue) {
taosCloseQueue(pQueue); taosCloseQueue(pQueue);
uDebug("worker:%s, queue:%p is freed", pPool->name, pQueue); uDebug("workers:%s, queue:%p is freed", pool->name, pQueue);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册