Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d20aa8f8
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d20aa8f8
编写于
10月 04, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10430] check util and common files
上级
1c40f32e
变更
58
隐藏空白更改
内联
并排
Showing
58 changed file
with
229 addition
and
274 deletion
+229
-274
include/common/schema.h
include/common/schema.h
+3
-3
include/common/taosdef.h
include/common/taosdef.h
+3
-3
include/common/taoserror.h
include/common/taoserror.h
+3
-3
include/common/taosmsg.h
include/common/taosmsg.h
+3
-3
include/common/tarithoperator.h
include/common/tarithoperator.h
+3
-3
include/common/tcmdtype.h
include/common/tcmdtype.h
+3
-3
include/common/tdataformat.h
include/common/tdataformat.h
+3
-3
include/common/texpr.h
include/common/texpr.h
+3
-3
include/common/tglobal.h
include/common/tglobal.h
+6
-4
include/common/tlocale.h
include/common/tlocale.h
+3
-3
include/common/tname.h
include/common/tname.h
+3
-3
include/common/trow.h
include/common/trow.h
+3
-3
include/common/ttimezone.h
include/common/ttimezone.h
+3
-3
include/common/ttoken.h
include/common/ttoken.h
+3
-3
include/common/ttokendef.h
include/common/ttokendef.h
+3
-3
include/common/ttype.h
include/common/ttype.h
+3
-3
include/common/tvariant.h
include/common/tvariant.h
+3
-3
include/os/osDef.h
include/os/osDef.h
+0
-9
include/os/osSysinfo.h
include/os/osSysinfo.h
+1
-1
include/util/hashfunc.h
include/util/hashfunc.h
+3
-3
include/util/tchecksum.h
include/util/tchecksum.h
+4
-12
include/util/tcompare.h
include/util/tcompare.h
+3
-3
include/util/tconfig.h
include/util/tconfig.h
+2
-2
include/util/tdef.h
include/util/tdef.h
+9
-0
include/util/tfile.h
include/util/tfile.h
+3
-3
include/util/tfunctional.h
include/util/tfunctional.h
+3
-3
include/util/tidpool.h
include/util/tidpool.h
+3
-3
include/util/tkey.h
include/util/tkey.h
+3
-3
include/util/tlog.h
include/util/tlog.h
+0
-1
include/util/tlosertree.h
include/util/tlosertree.h
+3
-5
include/util/tmd5.h
include/util/tmd5.h
+3
-5
include/util/tmempool.h
include/util/tmempool.h
+3
-3
include/util/tnote.h
include/util/tnote.h
+3
-3
include/util/tqueue.h
include/util/tqueue.h
+3
-3
include/util/tref.h
include/util/tref.h
+3
-3
include/util/tsched.h
include/util/tsched.h
+3
-3
include/util/tscompression.h
include/util/tscompression.h
+3
-3
include/util/tskiplist.h
include/util/tskiplist.h
+3
-3
include/util/tsocket.h
include/util/tsocket.h
+0
-48
include/util/tstrbuild.h
include/util/tstrbuild.h
+3
-3
include/util/tthread.h
include/util/tthread.h
+3
-3
include/util/ttimer.h
include/util/ttimer.h
+3
-3
include/util/tulog.h
include/util/tulog.h
+3
-3
include/util/tutil.h
include/util/tutil.h
+6
-5
include/util/tworker.h
include/util/tworker.h
+17
-14
source/common/src/tglobal.c
source/common/src/tglobal.c
+1
-21
source/libs/transport/src/rpcMain.c
source/libs/transport/src/rpcMain.c
+0
-1
source/libs/transport/src/rpcTcp.c
source/libs/transport/src/rpcTcp.c
+0
-1
source/libs/transport/src/rpcUdp.c
source/libs/transport/src/rpcUdp.c
+0
-1
source/server/dnode/src/dnodeTelemetry.c
source/server/dnode/src/dnodeTelemetry.c
+0
-1
source/server/dnode/src/dnodeTrans.c
source/server/dnode/src/dnodeTrans.c
+1
-1
source/util/src/hash.c
source/util/src/hash.c
+1
-0
source/util/src/tcompare.c
source/util/src/tcompare.c
+16
-7
source/util/src/tconfig.c
source/util/src/tconfig.c
+0
-1
source/util/src/tlog.c
source/util/src/tlog.c
+1
-1
source/util/src/tlosertree.c
source/util/src/tlosertree.c
+0
-1
source/util/src/ttimer.c
source/util/src/ttimer.c
+3
-0
source/util/src/tworker.c
source/util/src/tworker.c
+56
-33
未找到文件。
include/common/schema.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
\ No newline at end of file
#endif
/*_TD_COMMON_SCHEMA_H_*/
\ No newline at end of file
include/common/taosdef.h
浏览文件 @
d20aa8f8
...
...
@@ -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
_
*/
include/common/taoserror.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/taosmsg.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/tarithoperator.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/tcmdtype.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/tdataformat.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/texpr.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/tglobal.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/tlocale.h
浏览文件 @
d20aa8f8
...
...
@@ -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
include/common/tname.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/trow.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_
T
ROW_H_
#define _TD_
T
ROW_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
include/common/ttimezone.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/ttoken.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/ttokendef.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/common/ttype.h
浏览文件 @
d20aa8f8
#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_*/
include/common/tvariant.h
浏览文件 @
d20aa8f8
...
...
@@ -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_*/
include/os/osDef.h
浏览文件 @
d20aa8f8
...
...
@@ -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
...
...
include/os/osSysinfo.h
浏览文件 @
d20aa8f8
...
...
@@ -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
;
...
...
include/util/hashfunc.h
浏览文件 @
d20aa8f8
...
...
@@ -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*/
include/util/tchecksum.h
浏览文件 @
d20aa8f8
...
...
@@ -13,22 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
CHECKSUM_H
#define
TDENGINE_T
CHECKSUM_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*/
include/util/tcompare.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
COMPARE_H
#define
TDENGINE_T
COMPARE_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*/
include/util/tconfig.h
浏览文件 @
d20aa8f8
...
...
@@ -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
}
...
...
include/util/tdef.h
浏览文件 @
d20aa8f8
...
...
@@ -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
...
...
include/util/tfile.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
FILE_H
#define
TDENGINE_T
FILE_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*/
include/util/tfunctional.h
浏览文件 @
d20aa8f8
...
...
@@ -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_T
FUNCTIONAL_H
#define
TD_T
FUNCTIONAL_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*/
include/util/tidpool.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
IDPOOL_H
#define
TDENGINE_T
IDPOOL_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*/
include/util/tkey.h
浏览文件 @
d20aa8f8
...
...
@@ -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_T
KEY_H
#define
TDENGINE_T
KEY_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
include/util/tlog.h
浏览文件 @
d20aa8f8
...
...
@@ -20,7 +20,6 @@
extern
"C"
{
#endif
// log
extern
int8_t
tsAsyncLog
;
extern
int32_t
tsNumOfLogLines
;
...
...
include/util/tlosertree.h
浏览文件 @
d20aa8f8
...
...
@@ -13,15 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
LOSERTREE_H
#define
TDENGINE_T
LOSERTREE_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*/
include/util/tmd5.h
浏览文件 @
d20aa8f8
...
...
@@ -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*/
include/util/tmempool.h
浏览文件 @
d20aa8f8
...
...
@@ -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_T
MEMPOOL_H
#define
TDENGINE_T
MEMPOOL_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*/
include/util/tnote.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
NOTE_H
#define
TDENGINE_T
NOTE_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*/
include/util/tqueue.h
浏览文件 @
d20aa8f8
...
...
@@ -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*/
include/util/tref.h
浏览文件 @
d20aa8f8
...
...
@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
REF_H
#define
TDENGINE_T
REF_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*/
include/util/tsched.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
SCHED_H
#define
TDENGINE_T
SCHED_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*/
include/util/tscompression.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_TS
COMPRESSION_H
#define
TDENGINE_TS
COMPRESSION_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
include/util/tskiplist.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_TSKIP
LIST_H
#define
TDENGINE_TSKIP
LIST_H
#ifndef
_TD_UTIL_SKI
LIST_H
#define
_TD_UTIL_SKI
LIST_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*/
include/util/tsocket.h
已删除
100644 → 0
浏览文件 @
1c40f32e
/*
* 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
include/util/tstrbuild.h
浏览文件 @
d20aa8f8
...
...
@@ -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
\ No newline at end of file
#endif
/*_TD_UTIL_STRING_BUILDER_H*/
\ No newline at end of file
include/util/tthread.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
THREAD_H
#define
TDENGINE_T
THREAD_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*/
include/util/ttimer.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
TIMER_H
#define
TDENGINE_T
TIMER_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*/
include/util/tulog.h
浏览文件 @
d20aa8f8
...
...
@@ -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*/
include/util/tutil.h
浏览文件 @
d20aa8f8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
UTIL_H
#define
TDENGINE_T
UTIL_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*/
include/util/tworker.h
浏览文件 @
d20aa8f8
...
...
@@ -13,30 +13,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef
TDENGINE_T
WORKER_H
#define
TDENGINE_T
WORKER_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
*
p
P
ool
;
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*/
source/common/src/tglobal.c
浏览文件 @
d20aa8f8
...
...
@@ -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
;
}
...
...
source/libs/transport/src/rpcMain.c
浏览文件 @
d20aa8f8
...
...
@@ -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"
...
...
source/libs/transport/src/rpcTcp.c
浏览文件 @
d20aa8f8
...
...
@@ -14,7 +14,6 @@
*/
#include "os.h"
#include "tsocket.h"
#include "tutil.h"
#include "taosdef.h"
#include "taoserror.h"
...
...
source/libs/transport/src/rpcUdp.c
浏览文件 @
d20aa8f8
...
...
@@ -14,7 +14,6 @@
*/
#include "os.h"
#include "tsocket.h"
#include "ttimer.h"
#include "tutil.h"
#include "taosdef.h"
...
...
source/server/dnode/src/dnodeTelemetry.c
浏览文件 @
d20aa8f8
...
...
@@ -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"
...
...
source/server/dnode/src/dnodeTrans.c
浏览文件 @
d20aa8f8
...
...
@@ -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
;
...
...
source/util/src/hash.c
浏览文件 @
d20aa8f8
...
...
@@ -16,6 +16,7 @@
#include "os.h"
#include "hash.h"
#include "tulog.h"
#include "tdef.h"
#define EXT_SIZE 1024
...
...
source/util/src/tcompare.c
浏览文件 @
d20aa8f8
...
...
@@ -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
;
}
}
...
...
source/util/src/tconfig.c
浏览文件 @
d20aa8f8
...
...
@@ -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
}};
...
...
source/util/src/tlog.c
浏览文件 @
d20aa8f8
...
...
@@ -154,7 +154,7 @@ static bool taosLockLogFile(int32_t fd) {
if
(
fd
<
0
)
return
false
;
if
(
tsLogObj
.
fileNum
>
1
)
{
int32_t
ret
=
taos
Un
LockFile
(
fd
);
int32_t
ret
=
taosLockFile
(
fd
);
if
(
ret
==
0
)
{
return
true
;
}
...
...
source/util/src/tlosertree.c
浏览文件 @
d20aa8f8
...
...
@@ -15,7 +15,6 @@
#include "os.h"
#include "tlosertree.h"
// #include "taosmsg.h"
#include "tulog.h"
// set initial value for loser tree
...
...
source/util/src/ttimer.c
浏览文件 @
d20aa8f8
...
...
@@ -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
);
...
...
source/util/src/tworker.c
浏览文件 @
d20aa8f8
...
...
@@ -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
->
p
Pool
=
pP
ool
;
pWorker
->
p
ool
=
p
ool
;
}
uInfo
(
"worker:%s is initialized, min:%d max:%d"
,
p
Pool
->
name
,
pPool
->
min
,
pP
ool
->
max
);
uInfo
(
"worker:%s is initialized, min:%d max:%d"
,
p
ool
->
name
,
pool
->
min
,
p
ool
->
max
);
return
0
;
}
void
tWorkerCleanup
(
SWorkerPool
*
p
P
ool
)
{
for
(
int
i
=
0
;
i
<
p
P
ool
->
max
;
++
i
)
{
SWorker
*
pWorker
=
p
Pool
->
worker
+
i
;
void
tWorkerCleanup
(
SWorkerPool
*
pool
)
{
for
(
int
i
=
0
;
i
<
pool
->
max
;
++
i
)
{
SWorker
*
pWorker
=
p
ool
->
workers
+
i
;
if
(
taosCheckPthreadValid
(
pWorker
->
thread
))
{
taosQsetThreadResume
(
p
P
ool
->
qset
);
taosQsetThreadResume
(
pool
->
qset
);
}
}
for
(
int
i
=
0
;
i
<
p
P
ool
->
max
;
++
i
)
{
SWorker
*
pWorker
=
p
Pool
->
worker
+
i
;
for
(
int
i
=
0
;
i
<
pool
->
max
;
++
i
)
{
SWorker
*
pWorker
=
p
ool
->
workers
+
i
;
if
(
taosCheckPthreadValid
(
pWorker
->
thread
))
{
pthread_join
(
pWorker
->
thread
,
NULL
);
}
}
free
(
p
Pool
->
worker
);
taosCloseQset
(
p
P
ool
->
qset
);
pthread_mutex_destroy
(
&
p
P
ool
->
mutex
);
free
(
p
ool
->
workers
);
taosCloseQset
(
pool
->
qset
);
pthread_mutex_destroy
(
&
pool
->
mutex
);
uInfo
(
"worker:%s is closed"
,
p
P
ool
->
name
);
uInfo
(
"worker:%s is closed"
,
pool
->
name
);
}
void
*
tWorkerAllocQueue
(
SWorkerPool
*
p
P
ool
,
void
*
ahandle
)
{
pthread_mutex_lock
(
&
p
P
ool
->
mutex
);
void
*
tWorkerAllocQueue
(
SWorkerPool
*
pool
,
void
*
ahandle
)
{
pthread_mutex_lock
(
&
pool
->
mutex
);
taos_queue
pQueue
=
taosOpenQueue
();
if
(
pQueue
==
NULL
)
{
pthread_mutex_unlock
(
&
p
P
ool
->
mutex
);
pthread_mutex_unlock
(
&
pool
->
mutex
);
return
NULL
;
}
taosAddIntoQset
(
p
P
ool
->
qset
,
pQueue
,
ahandle
);
taosAddIntoQset
(
pool
->
qset
,
pQueue
,
ahandle
);
// spawn a thread to process queue
if
(
p
Pool
->
num
<
pP
ool
->
max
)
{
if
(
p
ool
->
num
<
p
ool
->
max
)
{
do
{
SWorker
*
pWorker
=
p
Pool
->
worker
+
pP
ool
->
num
;
SWorker
*
pWorker
=
p
ool
->
workers
+
p
ool
->
num
;
pthread_attr_t
thAttr
;
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
pPool
->
worker
Fp
,
pWorker
)
!=
0
)
{
uError
(
"worker
:%s:%d failed to create thread to process since %s"
,
pP
ool
->
name
,
pWorker
->
id
,
strerror
(
errno
));
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
taosWorkerThread
Fp
,
pWorker
)
!=
0
)
{
uError
(
"worker
s:%s:%d failed to create thread to process since %s"
,
p
ool
->
name
,
pWorker
->
id
,
strerror
(
errno
));
}
pthread_attr_destroy
(
&
thAttr
);
p
P
ool
->
num
++
;
uDebug
(
"worker
:%s:%d is launched, total:%d"
,
pPool
->
name
,
pWorker
->
id
,
pP
ool
->
num
);
}
while
(
p
Pool
->
num
<
pP
ool
->
min
);
pool
->
num
++
;
uDebug
(
"worker
s:%s:%d is launched, total:%d"
,
pool
->
name
,
pWorker
->
id
,
p
ool
->
num
);
}
while
(
p
ool
->
num
<
p
ool
->
min
);
}
pthread_mutex_unlock
(
&
p
P
ool
->
mutex
);
uDebug
(
"worker
:%s, queue:%p is allocated, ahandle:%p"
,
pP
ool
->
name
,
pQueue
,
ahandle
);
pthread_mutex_unlock
(
&
pool
->
mutex
);
uDebug
(
"worker
s:%s, queue:%p is allocated, ahandle:%p"
,
p
ool
->
name
,
pQueue
,
ahandle
);
return
pQueue
;
}
void
tWorkerFreeQueue
(
SWorkerPool
*
p
P
ool
,
void
*
pQueue
)
{
void
tWorkerFreeQueue
(
SWorkerPool
*
pool
,
void
*
pQueue
)
{
taosCloseQueue
(
pQueue
);
uDebug
(
"worker
:%s, queue:%p is freed"
,
pP
ool
->
name
,
pQueue
);
uDebug
(
"worker
s:%s, queue:%p is freed"
,
p
ool
->
name
,
pQueue
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录