Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cfc63289
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
cfc63289
编写于
12月 10, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] refactor and add test cases.
上级
770e0331
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
357 addition
and
301 deletion
+357
-301
include/common/tep.h
include/common/tep.h
+1
-1
include/common/tglobal.h
include/common/tglobal.h
+1
-1
include/os/osSemaphore.h
include/os/osSemaphore.h
+1
-1
include/util/tconfig.h
include/util/tconfig.h
+4
-4
source/client/CMakeLists.txt
source/client/CMakeLists.txt
+2
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+13
-1
source/client/src/client.c
source/client/src/client.c
+47
-6
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+30
-55
source/client/src/tscEnv.c
source/client/src/tscEnv.c
+73
-67
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+37
-0
source/common/src/tep.c
source/common/src/tep.c
+3
-1
source/common/src/tglobal.c
source/common/src/tglobal.c
+124
-140
source/dnode/mgmt/daemon/src/daemon.c
source/dnode/mgmt/daemon/src/daemon.c
+1
-1
source/os/src/osSemaphore.c
source/os/src/osSemaphore.c
+3
-3
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+8
-8
source/util/src/tconfig.c
source/util/src/tconfig.c
+3
-4
source/util/src/tlog.c
source/util/src/tlog.c
+2
-2
source/util/src/ttimer.c
source/util/src/ttimer.c
+4
-6
未找到文件。
include/common/tep.h
浏览文件 @
cfc63289
#ifndef TDENGINE_TEP_H
#define TDENGINE_TEP_H
int
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
);
int
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
);
#endif // TDENGINE_TEP_H
include/common/tglobal.h
浏览文件 @
cfc63289
...
...
@@ -185,7 +185,7 @@ extern SDiskCfg tsDiskCfg[];
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
void
taosInitGlobalCfg
();
int32_t
taosCheck
Global
Cfg
();
int32_t
taosCheck
AndPrint
Cfg
();
int32_t
taosCfgDynamicOptions
(
char
*
msg
);
bool
taosCheckBalanceCfgOptions
(
const
char
*
option
,
int32_t
*
vnodeId
,
int32_t
*
dnodeId
);
void
taosAddDataDir
(
int
index
,
char
*
v1
,
int
level
,
int
primary
);
...
...
include/os/osSemaphore.h
浏览文件 @
cfc63289
...
...
@@ -57,7 +57,7 @@ int64_t taosGetPthreadId(pthread_t thread);
void
taosResetPthread
(
pthread_t
*
thread
);
bool
taosComparePthread
(
pthread_t
first
,
pthread_t
second
);
int32_t
taosGetPId
();
int32_t
taosGet
CurrentAPP
Name
(
char
*
name
,
int32_t
*
len
);
int32_t
taosGet
App
Name
(
char
*
name
,
int32_t
*
len
);
#ifdef __cplusplus
}
...
...
include/util/tconfig.h
浏览文件 @
cfc63289
...
...
@@ -20,7 +20,7 @@
extern
"C"
{
#endif
#define TSDB_CFG_MAX_NUM 1
23
#define TSDB_CFG_MAX_NUM 1
19
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
...
...
@@ -83,11 +83,11 @@ extern int32_t tsGlobalConfigNum;
extern
char
*
tsCfgStatusStr
[];
void
taosReadGlobalLogCfg
();
int32_t
taosRead
GlobalCfg
();
void
taosPrint
Global
Cfg
();
int32_t
taosRead
CfgFromFile
();
void
taosPrintCfg
();
void
taosDumpGlobalCfg
();
void
taos
Init
ConfigOption
(
SGlobalCfg
cfg
);
void
taos
Add
ConfigOption
(
SGlobalCfg
cfg
);
SGlobalCfg
*
taosGetConfigOption
(
const
char
*
option
);
#ifdef __cplusplus
...
...
source/client/CMakeLists.txt
浏览文件 @
cfc63289
...
...
@@ -10,3 +10,5 @@ target_link_libraries(
INTERFACE api
PRIVATE os util common transport parser
)
ADD_SUBDIRECTORY
(
test
)
\ No newline at end of file
source/client/inc/clientInt.h
浏览文件 @
cfc63289
...
...
@@ -61,7 +61,7 @@ typedef struct SAppInstInfo {
typedef
struct
SAppInfo
{
int64_t
startTime
;
char
appName
[
TSDB_APPNAME_LEN
];
char
appName
[
TSDB_APP
_
NAME_LEN
];
char
*
ep
;
int32_t
pid
;
int32_t
numOfThreads
;
...
...
@@ -102,11 +102,23 @@ typedef struct SRequestObj {
void
*
pInfo
;
// sql parse info, generated by parser module
}
SRequestObj
;
extern
int32_t
tscReqRef
;
extern
void
*
tscQhandle
;
extern
int32_t
tscConnRef
;
extern
void
*
tscRpcCache
;
extern
pthread_mutex_t
rpcObjMutex
;
void
*
createTscObj
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
ip
,
uint32_t
port
);
void
destroyTscObj
(
void
*
pTscObj
);
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
);
void
destroyRequest
(
void
*
p
);
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
void
taos_init_imp
(
void
);
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
pStr
);
#ifdef __cplusplus
}
#endif
...
...
source/client/src/client.c
浏览文件 @
cfc63289
...
...
@@ -13,11 +13,52 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#include "taos.h"
#include "os.h"
#include "tdef.h"
//TAOS_RES *taos_query(TAOS *taos, const char *sql) {
//
//}
#include "tglobal.h"
#include "clientInt.h"
#include "tscLog.h"
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
int32_t
p
=
(
port
!=
0
)
?
port
:
tsServerPort
;
tscDebug
(
"try to connect to %s:%u, user:%s db:%s"
,
ip
,
p
,
user
,
db
);
if
(
user
==
NULL
)
{
user
=
TSDB_DEFAULT_USER
;
}
if
(
pass
==
NULL
)
{
pass
=
TSDB_DEFAULT_PASS
;
}
return
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
p
);
}
TAOS
*
taos_connect_auth
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
)
{
tscDebug
(
"try to connect to %s:%u by auth, user:%s db:%s"
,
ip
,
port
,
user
,
db
);
if
(
user
==
NULL
)
{
user
=
TSDB_DEFAULT_USER
;
}
if
(
auth
==
NULL
)
{
tscError
(
"No auth info is given, failed to connect to server"
);
return
NULL
;
}
return
taos_connect_internal
(
ip
,
user
,
NULL
,
auth
,
db
,
port
);
}
TAOS
*
taos_connect_l
(
const
char
*
ip
,
int
ipLen
,
const
char
*
user
,
int
userLen
,
const
char
*
pass
,
int
passLen
,
const
char
*
db
,
int
dbLen
,
uint16_t
port
)
{
char
ipStr
[
TSDB_EP_LEN
]
=
{
0
};
char
dbStr
[
TSDB_DB_NAME_LEN
]
=
{
0
};
char
userStr
[
TSDB_USER_LEN
]
=
{
0
};
char
passStr
[
TSDB_KEY_LEN
]
=
{
0
};
strncpy
(
ipStr
,
ip
,
MIN
(
TSDB_EP_LEN
-
1
,
ipLen
));
strncpy
(
userStr
,
user
,
MIN
(
TSDB_USER_LEN
-
1
,
userLen
));
strncpy
(
passStr
,
pass
,
MIN
(
TSDB_KEY_LEN
-
1
,
passLen
));
strncpy
(
dbStr
,
db
,
MIN
(
TSDB_DB_NAME_LEN
-
1
,
dbLen
));
return
taos_connect
(
ipStr
,
userStr
,
passStr
,
dbStr
,
port
);
}
int
taos_init
()
{
return
0
;
}
void
taos_cleanup
(
void
)
{}
source/client/src/clientImpl.c
浏览文件 @
cfc63289
...
...
@@ -33,11 +33,9 @@ static bool validateDbName(const char* db) {
return
stringLengthCheck
(
db
,
TSDB_DB_NAME_LEN
-
1
);
}
static
S
Request
Obj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
);
static
S
Tsc
Obj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
);
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
)
{
STscObj
*
pObj
=
NULL
;
if
(
!
validateUserName
(
user
))
{
terrno
=
TSDB_CODE_TSC_INVALID_USER_LENGTH
;
return
NULL
;
...
...
@@ -81,34 +79,7 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
}
}
SRequestObj
*
pRequest
=
taosConnectImpl
(
ip
,
user
,
auth
,
db
,
port
,
NULL
,
NULL
);
if
(
pRequest
!=
NULL
)
{
pObj
=
pRequest
->
pTscObj
;
pRequest
->
body
.
fp
=
NULL
;
pRequest
->
body
.
param
=
pRequest
;
// tscBuildAndSendRequest(pRequest, NULL);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
code
==
TSDB_CODE_RPC_FQDN_ERROR
)
{
printf
(
"taos connect failed, reason: %s
\n\n
"
,
taos_errstr
(
pRequest
));
}
else
{
printf
(
"taos connect failed, reason: %s.
\n\n
"
,
tstrerror
(
terrno
));
}
taos_free_result
(
pRequest
);
taos_close
(
pObj
);
return
NULL
;
}
// tscDebug("%p DB connection is opening, rpcObj: %p, dnodeConn:%p", pObj, pObj->pRpcObj, pObj->pRpcObj->pDnodeConn);
taos_free_result
(
pRequest
);
return
pObj
;
}
return
NULL
;
return
taosConnectImpl
(
ip
,
user
,
auth
,
db
,
port
,
NULL
,
NULL
);
}
int
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SRpcCorEpSet
*
pEpSet
)
{
...
...
@@ -147,7 +118,7 @@ int initEpSetFromCfg(const char *firstEp, const char *secondEp, SRpcCorEpSet *pE
return
0
;
}
S
Request
Obj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
)
{
S
Tsc
Obj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
)
{
if
(
taos_init
()
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
...
...
@@ -155,36 +126,40 @@ SRequestObj* taosConnectImpl(const char *ip, const char *user, const char *auth,
STscObj
*
pObj
=
createTscObj
(
user
,
auth
,
ip
,
port
);
if
(
NULL
==
pObj
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
return
pObj
;
}
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
calloc
(
1
,
sizeof
(
SRequestObj
));
if
(
NULL
==
pRequest
)
{
// void *pRpcObj = NULL;
//
// char rpcKey[512] = {0};
// snprintf(rpcKey, sizeof(rpcKey), "%s:%s:%s:%d", user, auth, ip, port);
// if (tscAcquireRpc(rpcKey, user, auth, &pRpcObj) != 0) {
// terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
// return NULL;
// }
SRequestObj
*
pRequest
=
createRequest
(
pObj
,
fp
,
param
,
TSDB_SQL_CONNECT
);
if
(
pRequest
==
NULL
)
{
destroyTscObj
(
pObj
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
free
(
pObj
);
return
NULL
;
}
void
*
pRpcObj
=
NULL
;
// tscBuildAndSendRequest(pRequest, NULL);
// tsem_wait(&pRequest->body.rspSem);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
const
char
*
errorMsg
=
(
pRequest
->
code
==
TSDB_CODE_RPC_FQDN_ERROR
)
?
taos_errstr
(
pRequest
)
:
tstrerror
(
terrno
);
printf
(
"connect failed, reason: %s
\n\n
"
,
errorMsg
);
char
rpcKey
[
512
]
=
{
0
};
snprintf
(
rpcKey
,
sizeof
(
rpcKey
),
"%s:%s:%s:%d"
,
user
,
auth
,
ip
,
port
);
if
(
tscAcquireRpc
(
rpcKey
,
user
,
auth
,
&
pRpcObj
)
!=
0
)
{
terrno
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
taos_free_result
(
pRequest
);
taos_close
(
pObj
);
return
NULL
;
}
pObj
->
pRpcObj
=
(
SRpcObj
*
)
pRpcObj
;
pRequest
->
pTscObj
=
pObj
;
pRequest
->
body
.
fp
=
fp
;
pRequest
->
body
.
param
=
param
;
pRequest
->
type
=
TSDB_SQL_CONNECT
;
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
pObj
->
id
=
taosAddRef
(
tscConn
,
pObj
);
registerSqlObj
(
pRequest
);
return
pRequest
;
// tscDebug("0x%"PRIx64" connection is opening, rpcObj: %p, dnodeConn:%p", pObj, pObj->pRpcObj,
// pObj->pRpcObj->pDnodeConn);
destroyRequest
(
pRequest
);
return
pObj
;
}
\ No newline at end of file
source/client/src/tscEnv.c
浏览文件 @
cfc63289
...
...
@@ -31,14 +31,12 @@
#define TSC_VAR_RELEASED 0
SAppInfo
appInfo
;
int32_t
sentinel
=
TSC_VAR_NOT_RELEASE
;
int32_t
tscReqRef
=
-
1
;
void
*
tscQhandle
;
int32_t
tscConnRef
=
-
1
;
void
*
tscRpcCache
;
// TODO removed from here.
static
pthread_mutex_t
rpcObjMutex
;
// mutex to protect open the rpc obj concurrently
pthread_mutex_t
rpcObjMutex
;
// mutex to protect open the rpc obj concurrently
static
pthread_once_t
tscinit
=
PTHREAD_ONCE_INIT
;
static
pthread_mutex_t
setConfMutex
=
PTHREAD_MUTEX_INITIALIZER
;
...
...
@@ -104,7 +102,6 @@ void* tscAcquireRpc(const char *key, const char *user, const char *secretEncrypt
pthread_mutex_unlock(&rpcObjMutex);
return pRpcObj;
#endif
}
void
destroyTscObj
(
void
*
pTscObj
)
{
...
...
@@ -139,6 +136,72 @@ void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t
tstrncpy
(
pObj
->
pass
,
auth
,
len
);
pthread_mutex_init
(
&
pObj
->
mutex
,
NULL
);
pObj
->
id
=
taosAddRef
(
tscConnRef
,
pObj
);
}
static
void
registerRequest
(
SRequestObj
*
pRequest
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taosAcquireRef
(
tscConnRef
,
pRequest
->
pTscObj
->
id
);
assert
(
pTscObj
!=
NULL
);
// connection has been released already, abort creating request.
pRequest
->
self
=
taosAddRef
(
tscReqRef
,
pRequest
);
int32_t
num
=
atomic_add_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
SInstanceActivity
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
int32_t
total
=
atomic_add_fetch_32
(
&
pActivity
->
totalRequests
,
1
);
int32_t
currentInst
=
atomic_add_fetch_32
(
&
pActivity
->
currentRequests
,
1
);
tscDebug
(
"0x%"
PRIx64
" new Request from 0x%"
PRIx64
", current:%d, app current:%d, total:%d"
,
pRequest
->
self
,
pRequest
->
pTscObj
->
id
,
num
,
currentInst
,
total
);
}
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
)
{
assert
(
pObj
!=
NULL
);
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
calloc
(
1
,
sizeof
(
SRequestObj
));
if
(
NULL
==
pRequest
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
}
// TODO generated request uuid
pRequest
->
requestId
=
0
;
pRequest
->
type
=
type
;
pRequest
->
pTscObj
=
pObj
;
pRequest
->
body
.
fp
=
fp
;
pRequest
->
body
.
param
=
param
;
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
registerRequest
(
pRequest
);
}
static
void
deregisterRequest
(
SRequestObj
*
pRequest
)
{
assert
(
pRequest
!=
NULL
);
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SInstanceActivity
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
taosReleaseRef
(
tscReqRef
,
pRequest
->
self
);
int32_t
currentInst
=
atomic_sub_fetch_32
(
&
pActivity
->
currentRequests
,
1
);
int32_t
num
=
atomic_sub_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
tscDebug
(
"0x%"
PRIx64
" free Request from 0x%"
PRIx64
", current:%d, app current:%d"
,
pRequest
->
self
,
pTscObj
->
id
,
num
,
currentInst
);
taosReleaseRef
(
tscConnRef
,
pTscObj
->
id
);
}
void
destroyRequest
(
void
*
p
)
{
assert
(
p
!=
NULL
);
SRequestObj
*
pRequest
=
*
(
SRequestObj
**
)
p
;
assert
(
RID_VALID
(
pRequest
->
self
));
tfree
(
pRequest
->
msgBuf
);
tfree
(
pRequest
->
sqlstr
);
tfree
(
pRequest
->
pInfo
);
deregisterRequest
(
pRequest
);
}
static
void
tscInitLogFile
()
{
...
...
@@ -167,11 +230,10 @@ void taos_init_imp(void) {
deltaToUtcInitOnce
();
taosInitGlobalCfg
();
taosRead
GlobalCfg
();
taosRead
CfgFromFile
();
tscInitLogFile
();
if
(
taosCheckGlobalCfg
())
{
if
(
taosCheckAndPrintCfg
())
{
tscInitRes
=
-
1
;
return
;
}
...
...
@@ -179,8 +241,7 @@ void taos_init_imp(void) {
taosInitNotes
();
rpcInit
();
tscDebug
(
"starting to initialize TAOS client ..."
);
tscDebug
(
"Local End Point is:%s"
,
tsLocalEp
);
tscDebug
(
"starting to initialize TAOS client ...
\n
Local End Point is:%s"
,
tsLocalEp
);
taosSetCoreDump
(
true
);
...
...
@@ -202,55 +263,16 @@ void taos_init_imp(void) {
pthread_mutex_init
(
&
rpcObjMutex
,
NULL
);
tscConnRef
=
taosOpenRef
(
200
,
destroyTscObj
);
tscReqRef
=
taosOpenRef
(
40960
,
tscFreeRegisteredSqlObj
);
tscReqRef
=
taosOpenRef
(
40960
,
destroyRequest
);
taosGet
CurrentAPP
Name
(
appInfo
.
appName
,
NULL
);
taosGet
App
Name
(
appInfo
.
appName
,
NULL
);
appInfo
.
pid
=
taosGetPId
();
appInfo
.
startTime
=
taosGetTimestampMs
();
tscDebug
(
"client is initialized successfully"
);
}
int
taos_init
()
{
pthread_once
(
&
tscinit
,
taos_init_imp
);
return
tscInitRes
;
}
// this function may be called by user or system, or by both simultaneously.
void
taos_cleanup
(
void
)
{
tscDebug
(
"start to cleanup client environment"
);
if
(
atomic_val_compare_exchange_32
(
&
sentinel
,
TSC_VAR_NOT_RELEASE
,
TSC_VAR_RELEASED
)
!=
TSC_VAR_NOT_RELEASE
)
{
return
;
}
int32_t
id
=
tscReqRef
;
tscReqRef
=
-
1
;
taosCloseRef
(
id
);
void
*
p
=
tscQhandle
;
tscQhandle
=
NULL
;
taosCleanUpScheduler
(
p
);
id
=
tscConnRef
;
tscConnRef
=
-
1
;
taosCloseRef
(
id
);
p
=
tscRpcCache
;
tscRpcCache
=
NULL
;
if
(
p
!=
NULL
)
{
taosCacheCleanup
(
p
);
pthread_mutex_destroy
(
&
rpcObjMutex
);
}
pthread_mutex_destroy
(
&
setConfMutex
);
rpcCleanup
();
taosCloseLog
();
}
static
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
pStr
)
{
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
pStr
)
{
SGlobalCfg
*
cfg
=
NULL
;
switch
(
option
)
{
...
...
@@ -405,22 +427,6 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
return
0
;
}
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...)
{
static
int32_t
lock
=
0
;
for
(
int
i
=
1
;
atomic_val_compare_exchange_32
(
&
lock
,
0
,
1
)
!=
0
;
++
i
)
{
if
(
i
%
1000
==
0
)
{
tscInfo
(
"haven't acquire lock after spin %d times."
,
i
);
sched_yield
();
}
}
int
ret
=
taos_options_imp
(
option
,
(
const
char
*
)
arg
);
atomic_store_32
(
&
lock
,
0
);
return
ret
;
}
#if 0
#include "cJSON.h"
static setConfRet taos_set_config_imp(const char *config){
...
...
source/client/test/clientTests.cpp
浏览文件 @
cfc63289
/*
* 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/>.
*/
#include <gtest/gtest.h>
#include <iostream>
#include "tglobal.h"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "taos.h"
namespace
{
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
TEST
(
testCase
,
driverInit_Test
)
{
taos_init
();
}
\ No newline at end of file
source/common/src/tep.c
浏览文件 @
cfc63289
#include "os.h"
#include "tep.h"
#include "tglobal.h"
int
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
)
{
*
port
=
0
;
...
...
source/common/src/tglobal.c
浏览文件 @
cfc63289
此差异已折叠。
点击以展开。
source/dnode/mgmt/daemon/src/daemon.c
浏览文件 @
cfc63289
...
...
@@ -117,7 +117,7 @@ int dmnReadConfig(const char *path) {
return
-
1
;
}
if
(
taosCheck
Global
Cfg
()
!=
0
)
{
if
(
taosCheck
AndPrint
Cfg
()
!=
0
)
{
uError
(
"failed to check global config"
);
return
-
1
;
}
...
...
source/os/src/osSemaphore.c
浏览文件 @
cfc63289
...
...
@@ -42,7 +42,7 @@ bool taosComparePthread(pthread_t first, pthread_t second) { return first.p == s
int32_t
taosGetPId
()
{
return
GetCurrentProcessId
();
}
int32_t
taosGet
CurrentAPP
Name
(
char
*
name
,
int32_t
*
len
)
{
int32_t
taosGet
App
Name
(
char
*
name
,
int32_t
*
len
)
{
char
filepath
[
1024
]
=
{
0
};
GetModuleFileName
(
NULL
,
filepath
,
MAX_PATH
);
...
...
@@ -358,7 +358,7 @@ bool taosComparePthread(pthread_t first, pthread_t second) { return pthread_equa
int32_t
taosGetPId
()
{
return
(
int32_t
)
getpid
();
}
int32_t
taosGet
CurrentAPP
Name
(
char
*
name
,
int32_t
*
len
)
{
int32_t
taosGet
App
Name
(
char
*
name
,
int32_t
*
len
)
{
char
buf
[
PATH_MAX
+
1
];
buf
[
0
]
=
'\0'
;
proc_name
(
getpid
(),
buf
,
sizeof
(
buf
)
-
1
);
...
...
@@ -392,7 +392,7 @@ void taosResetPthread(pthread_t* thread) { *thread = 0; }
bool
taosComparePthread
(
pthread_t
first
,
pthread_t
second
)
{
return
first
==
second
;
}
int32_t
taosGetPId
()
{
return
getpid
();
}
int32_t
taosGet
CurrentAPP
Name
(
char
*
name
,
int32_t
*
len
)
{
int32_t
taosGet
App
Name
(
char
*
name
,
int32_t
*
len
)
{
const
char
*
self
=
"/proc/self/exe"
;
char
path
[
PATH_MAX
]
=
{
0
};
...
...
source/os/src/osSysinfo.c
浏览文件 @
cfc63289
...
...
@@ -714,7 +714,7 @@ static void taosGetSystemLocale() { // get and set default locale
//printf("locale not configured, set to system default:%s", tsLocale);
}
/
* if user does not specify the charset, extract it from locale */
/
/ if user does not specify the charset, extract it from locale
char
*
str
=
strrchr
(
tsLocale
,
sep
);
if
(
str
!=
NULL
)
{
str
++
;
...
...
@@ -1118,13 +1118,13 @@ char *taosGetCmdlineByPID(int pid) {
SysNameInfo
taosGetSysNameInfo
()
{
SysNameInfo
info
=
{
0
};
struct
utsname
buf
;
if
(
!
uname
(
&
buf
))
{
info
.
sysname
=
buf
.
sysname
;
info
.
sysname
==
buf
.
nodename
;
info
.
sysname
=
buf
.
release
;
info
.
sysname
=
buf
.
version
;
info
.
sysname
=
buf
.
machine
;
struct
utsname
uts
;
if
(
!
uname
(
&
uts
))
{
info
.
sysname
=
strdup
(
uts
.
sysname
)
;
info
.
nodename
=
strdup
(
uts
.
nodename
)
;
info
.
release
=
strdup
(
uts
.
release
)
;
info
.
version
=
strdup
(
uts
.
version
)
;
info
.
machine
=
strdup
(
uts
.
machine
)
;
}
return
info
;
...
...
source/util/src/tconfig.c
浏览文件 @
cfc63289
...
...
@@ -282,7 +282,7 @@ static void taosReadConfigOption(const char *option, char *value, char *value2,
}
}
void
taos
Init
ConfigOption
(
SGlobalCfg
cfg
)
{
void
taos
Add
ConfigOption
(
SGlobalCfg
cfg
)
{
tsGlobalConfig
[
tsGlobalConfigNum
++
]
=
cfg
;
}
...
...
@@ -335,7 +335,7 @@ void taosReadGlobalLogCfg() {
fclose
(
fp
);
}
int32_t
taosRead
GlobalCfg
()
{
int32_t
taosRead
CfgFromFile
()
{
char
*
line
,
*
option
,
*
value
,
*
value2
,
*
value3
;
int
olen
,
vlen
,
vlen2
,
vlen3
;
char
fileName
[
PATH_MAX
]
=
{
0
};
...
...
@@ -396,7 +396,7 @@ int32_t taosReadGlobalCfg() {
return
0
;
}
void
taosPrint
Global
Cfg
()
{
void
taosPrintCfg
()
{
uInfo
(
" taos config & system info:"
);
uInfo
(
"=================================="
);
...
...
@@ -443,7 +443,6 @@ void taosPrintGlobalCfg() {
}
taosPrintOsInfo
();
// taosPrintDataDirCfg();
uInfo
(
"=================================="
);
}
...
...
source/util/src/tlog.c
浏览文件 @
cfc63289
...
...
@@ -112,7 +112,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen
static
SLogBuff
*
taosLogBuffNew
(
int32_t
bufSize
);
static
void
taosCloseLogByFd
(
int32_t
oldFd
);
static
int32_t
taosOpenLogFile
(
char
*
fn
,
int32_t
maxLines
,
int32_t
maxFileNum
);
extern
void
taosPrint
Global
Cfg
();
extern
void
taosPrintCfg
();
static
int32_t
taosCompressFile
(
char
*
srcFileName
,
char
*
destFileName
);
static
int32_t
taosStartLog
()
{
...
...
@@ -222,7 +222,7 @@ static void *taosThreadToOpenNewFile(void *param) {
uInfo
(
" new log file:%d is opened"
,
tsLogObj
.
flag
);
uInfo
(
"=================================="
);
taosPrint
Global
Cfg
();
taosPrintCfg
();
taosKeepOldLog
(
keepName
);
return
NULL
;
...
...
source/util/src/ttimer.c
浏览文件 @
cfc63289
...
...
@@ -20,12 +20,10 @@
#include "tutil.h"
#include "taoserror.h"
extern
int8_t
tscEmbedded
;
#define tmrFatal(...) { if (tmrDebugFlag & DEBUG_FATAL) { taosPrintLog("TMR FATAL ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
#define tmrError(...) { if (tmrDebugFlag & DEBUG_ERROR) { taosPrintLog("TMR ERROR ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
#define tmrWarn(...) { if (tmrDebugFlag & DEBUG_WARN) { taosPrintLog("TMR WARN ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
#define tmrInfo(...) { if (tmrDebugFlag & DEBUG_INFO) { taosPrintLog("TMR ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
#define tmrFatal(...) { if (tmrDebugFlag & DEBUG_FATAL) { taosPrintLog("TMR FATAL ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrError(...) { if (tmrDebugFlag & DEBUG_ERROR) { taosPrintLog("TMR ERROR ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrWarn(...) { if (tmrDebugFlag & DEBUG_WARN) { taosPrintLog("TMR WARN ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrInfo(...) { if (tmrDebugFlag & DEBUG_INFO) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrDebug(...) { if (tmrDebugFlag & DEBUG_DEBUG) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrTrace(...) { if (tmrDebugFlag & DEBUG_TRACE) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录