[TD-10430] check util and common files
This commit is contained in:
parent
1c40f32e9c
commit
d20aa8f8f3
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
#endif /*_TD_COMMON_SCHEMA_H_*/
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* 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 _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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,13 +13,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
#endif /*_TD_COMMON_ROW_H_*/
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
||||
|
||||
|
|
|
@ -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_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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_*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,22 +13,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_TCHECKSUM_H
|
||||
#define TDENGINE_TCHECKSUM_H
|
||||
#ifndef _TD_UTIL_CHECKSUM_H
|
||||
#define _TD_UTIL_CHECKSUM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* 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 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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* 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_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
|
||||
#endif /*_TD_UTIL_KEY_H*/
|
|
@ -20,7 +20,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// log
|
||||
extern int8_t tsAsyncLog;
|
||||
extern int32_t tsNumOfLogLines;
|
||||
|
|
|
@ -13,15 +13,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_TLOSERTREE_H
|
||||
#define TDENGINE_TLOSERTREE_H
|
||||
#ifndef _TD_UTIL_LOSERTREE_H
|
||||
#define _TD_UTIL_LOSERTREE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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*/
|
||||
|
|
|
@ -22,10 +22,8 @@
|
|||
***********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _taos_md5_header_
|
||||
#define _taos_md5_header_
|
||||
|
||||
#include <stdint.h>
|
||||
#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*/
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* 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_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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
#endif /*_TD_UTIL_COMPRESSION_H*/
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* 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 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_STRING_BUILDER_H
|
||||
#define TDENGINE_STRING_BUILDER_H
|
||||
#ifndef _TD_UTIL_STRING_BUILDER_H
|
||||
#define _TD_UTIL_STRING_BUILDER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
@ -49,4 +49,4 @@ void taosStringBuilderAppendDouble(SStringBuilder* sb, double v);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /*_TD_UTIL_STRING_BUILDER_H*/
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -13,30 +13,33 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "os.h"
|
||||
#include "tsocket.h"
|
||||
#include "tutil.h"
|
||||
#include "taosdef.h"
|
||||
#include "taoserror.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "os.h"
|
||||
#include "tsocket.h"
|
||||
#include "ttimer.h"
|
||||
#include "tutil.h"
|
||||
#include "taosdef.h"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "os.h"
|
||||
#include "hash.h"
|
||||
#include "tulog.h"
|
||||
#include "tdef.h"
|
||||
|
||||
#define EXT_SIZE 1024
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include "os.h"
|
||||
#include "tlosertree.h"
|
||||
// #include "taosmsg.h"
|
||||
#include "tulog.h"
|
||||
|
||||
// set initial value for loser tree
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue