Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d43c0ab2
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d43c0ab2
编写于
2月 22, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
client can send msg to server
上级
5d965446
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
110 addition
and
111 deletion
+110
-111
src/client/src/tscServer.c
src/client/src/tscServer.c
+57
-80
src/client/src/tscSql.c
src/client/src/tscSql.c
+9
-3
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+19
-11
src/dnode/src/dnodeModule.c
src/dnode/src/dnodeModule.c
+0
-4
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+1
-1
src/inc/trpc.h
src/inc/trpc.h
+1
-1
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+4
-0
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+12
-10
src/plugins/monitor/src/monitorSystem.c
src/plugins/monitor/src/monitorSystem.c
+2
-1
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+1
-0
src/sdb/src/sdbEngine.c
src/sdb/src/sdbEngine.c
+4
-0
未找到文件。
src/client/src/tscServer.c
浏览文件 @
d43c0ab2
...
...
@@ -177,47 +177,28 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
}
int
tscSendMsgToServer
(
SSqlObj
*
pSql
)
{
uint8_t
code
=
TSDB_CODE_NETWORK_UNAVAIL
;
/*
* the total length of message
* rpc header + actual message body + digest
*
* the pSql object may be released automatically during insert procedure, in which the access of
* message body by using "if (pHeader->msgType & 1)" may cause the segment fault.
*
*/
// the memory will be released by taosProcessResponse, so no memory leak here
char
*
pStart
=
rpcMallocCont
(
pSql
->
cmd
.
payloadLen
);
if
(
NULL
==
pStart
)
{
char
*
pMsg
=
rpcMallocCont
(
pSql
->
cmd
.
payloadLen
);
if
(
NULL
==
pMsg
)
{
tscError
(
"%p msg:%s malloc fail"
,
pSql
,
taosMsg
[
pSql
->
cmd
.
msgType
]);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
tsc
Trace
(
"%p msg:%s is sent to server"
,
pSql
,
taosMsg
[
pSql
->
cmd
.
msgType
]
);
tsc
Print
(
"%p msg:%s is sent to server %d"
,
pSql
,
taosMsg
[
pSql
->
cmd
.
msgType
],
pSql
->
ipList
->
port
);
if
(
pStart
)
{
/*
* this SQL object may be released by other thread due to the completion of this query even before the log
* is dumped to log file. So the signature needs to be kept in a local variable.
*/
uint64_t
signature
=
(
uint64_t
)
pSql
->
signature
;
//if (tscUpdateVnodeMsg[pSql->cmd.command]) (*tscUpdateVnodeMsg[pSql->cmd.command])(pSql, pStart);
memcpy
(
pMsg
,
pSql
->
cmd
.
payload
,
pSql
->
cmd
.
payloadLen
);
pSql
->
ipList
->
ip
[
0
]
=
inet_addr
(
"192.168.0.1"
);
if
(
pSql
->
cmd
.
command
<
TSDB_SQL_MGMT
)
{
rpcSendRequest
(
pTscMgmtConn
,
pSql
->
ipList
,
pSql
->
cmd
.
msgType
,
pStart
,
pSql
->
cmd
.
payloadLen
,
pSql
);
rpcSendRequest
(
pVnodeConn
,
pSql
->
ipList
,
pSql
->
cmd
.
msgType
,
pMsg
,
pSql
->
cmd
.
payloadLen
,
pSql
);
}
else
{
rpcSendRequest
(
pVnodeConn
,
pSql
->
ipList
,
pSql
->
cmd
.
msgType
,
pStart
,
pSql
->
cmd
.
payloadLen
,
pSql
);
rpcSendRequest
(
pTscMgmtConn
,
pSql
->
ipList
,
pSql
->
cmd
.
msgType
,
pMsg
,
pSql
->
cmd
.
payloadLen
,
pSql
);
}
tscTrace
(
"%p send msg code:%d sig:%p"
,
pSql
,
code
,
signature
);
}
return
code
;
return
TSDB_CODE_SUCCESS
;
}
void
tscProcessMsgFromServer
(
char
type
,
void
*
pCont
,
int
contLen
,
void
*
ahandle
,
int32_t
code
)
{
tscPrint
(
"response is received, pCont:%p, code:%d"
,
pCont
,
code
);
SSqlObj
*
pSql
=
(
SSqlObj
*
)
ahandle
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
tscError
(
"%p sql is already released, signature:%p"
,
pSql
,
pSql
->
signature
);
...
...
@@ -237,6 +218,9 @@ void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle,
return
;
}
if
(
pCont
==
NULL
)
{
code
=
TSDB_CODE_NETWORK_UNAVAIL
;
}
else
{
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
if
(
code
==
TSDB_CODE_NOT_ACTIVE_TABLE
||
code
==
TSDB_CODE_INVALID_TABLE_ID
||
code
==
TSDB_CODE_INVALID_VNODE_ID
||
code
==
TSDB_CODE_NOT_ACTIVE_VNODE
||
...
...
@@ -264,7 +248,7 @@ void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle,
tscTrace
(
"%p it shall renew meter meta, code:%d"
,
pSql
,
code
);
pSql
->
maxRetry
=
TSDB_VNODES_SUPPORT
*
2
;
pSql
->
res
.
code
=
(
uint8_t
)
code
;
// keep the previous error code
pSql
->
res
.
code
=
(
uint8_t
)
code
;
// keep the previous error code
code
=
tscRenewMeterMeta
(
pSql
,
pMeterMetaInfo
->
name
);
...
...
@@ -275,10 +259,6 @@ void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle,
}
}
}
if
(
code
!=
TSDB_CODE_SUCCESS
){
// for other error set and return to invoker
rpcFreeCont
(
pCont
);
return
;
}
pSql
->
retry
=
0
;
...
...
@@ -2359,27 +2339,24 @@ int tscProcessRetrieveMetricRsp(SSqlObj *pSql) {
int
tscProcessEmptyResultRsp
(
SSqlObj
*
pSql
)
{
return
tscLocalResultCommonBuilder
(
pSql
,
0
);
}
int
tscBuildConnectMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SCMConnectMsg
*
pConnect
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
pMsg
=
pCmd
->
payload
+
tsRpcHeadSize
;
pStart
=
pMsg
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CONNECT
;
pCmd
->
payloadLen
=
sizeof
(
SCMConnectMsg
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
pConnect
=
(
SCMConnectMsg
*
)
pMsg
;
SCMConnectMsg
*
pConnect
=
(
SCMConnectMsg
*
)
pCmd
->
payload
;
char
*
db
;
// ugly code to move the space
db
=
strstr
(
pObj
->
db
,
TS_PATH_DELIMITER
);
db
=
(
db
==
NULL
)
?
pObj
->
db
:
db
+
1
;
strcpy
(
pConnect
->
db
,
db
);
strcpy
(
pConnect
->
clientVersion
,
version
);
pMsg
+=
sizeof
(
SCMConnectMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CONNECT
;
strcpy
(
pConnect
->
msgVersion
,
""
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/client/src/tscSql.c
浏览文件 @
d43c0ab2
...
...
@@ -64,11 +64,17 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const
}
if
(
ip
&&
ip
[
0
])
{
tscMgmtIpList
.
numOfIps
=
2
;
tscMgmtIpList
.
index
=
0
;
tscMgmtIpList
.
port
=
tsMgmtShellPort
;
tscMgmtIpList
.
numOfIps
=
1
;
tscMgmtIpList
.
ip
[
0
]
=
inet_addr
(
ip
);
if
(
tsMasterIp
[
0
]
&&
strcmp
(
ip
,
tsMasterIp
)
!=
0
)
{
tscMgmtIpList
.
numOfIps
=
2
;
tscMgmtIpList
.
ip
[
1
]
=
inet_addr
(
tsMasterIp
);
if
(
tsSecondIp
[
0
])
{
}
if
(
tsSecondIp
[
0
]
&&
strcmp
(
tsSecondIp
,
tsMasterIp
)
!=
0
)
{
tscMgmtIpList
.
numOfIps
=
3
;
tscMgmtIpList
.
ip
[
2
]
=
inet_addr
(
tsSecondIp
);
}
...
...
src/client/src/tscSystem.c
浏览文件 @
d43c0ab2
...
...
@@ -101,7 +101,7 @@ void taos_init_imp() {
tscMgmtIpList
.
numOfIps
=
1
;
tscMgmtIpList
.
ip
[
0
]
=
inet_addr
(
tsMasterIp
);
if
(
tsSecondIp
[
0
])
{
if
(
tsSecondIp
[
0
]
&&
strcmp
(
tsSecondIp
,
tsMasterIp
)
!=
0
)
{
tscMgmtIpList
.
numOfIps
=
2
;
tscMgmtIpList
.
ip
[
1
]
=
inet_addr
(
tsSecondIp
);
}
...
...
@@ -125,13 +125,13 @@ void taos_init_imp() {
}
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
rpcInit
.
localIp
=
tsLocalIp
;
rpcInit
.
localIp
=
"0.0.0.0"
;
//
tsLocalIp;
rpcInit
.
localPort
=
0
;
rpcInit
.
label
=
"TSC-vnode"
;
rpcInit
.
numOfThreads
=
tscNumOfThreads
;
rpcInit
.
a
fp
=
tscProcessMsgFromServer
;
rpcInit
.
c
fp
=
tscProcessMsgFromServer
;
rpcInit
.
sessions
=
tsMaxVnodeConnections
;
rpcInit
.
connType
=
TAOS_CONN_
SOCKET_TYPE_C
()
;
rpcInit
.
connType
=
TAOS_CONN_
CLIENT
;
pVnodeConn
=
rpcOpen
(
&
rpcInit
);
if
(
pVnodeConn
==
NULL
)
{
tscError
(
"failed to init connection to vnode"
);
...
...
@@ -139,13 +139,21 @@ void taos_init_imp() {
}
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
rpcInit
.
localIp
=
tsLocalIp
;
rpcInit
.
localIp
=
"0.0.0.0"
;
//
tsLocalIp;
rpcInit
.
localPort
=
0
;
rpcInit
.
label
=
"TSC-mgmt"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
a
fp
=
tscProcessMsgFromServer
;
rpcInit
.
c
fp
=
tscProcessMsgFromServer
;
rpcInit
.
sessions
=
tsMaxMgmtConnections
;
rpcInit
.
connType
=
TAOS_CONN_SOCKET_TYPE_C
();
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
idleTime
=
2000
;
rpcInit
.
user
=
"root"
;
rpcInit
.
ckey
=
"key"
;
char
secret
[
32
]
=
{
0
};
taosEncryptPass
((
uint8_t
*
)
"taosdata"
,
strlen
(
"taosdata"
),
secret
);
rpcInit
.
secret
=
secret
;
pTscMgmtConn
=
rpcOpen
(
&
rpcInit
);
if
(
pTscMgmtConn
==
NULL
)
{
tscError
(
"failed to init connection to mgmt"
);
...
...
@@ -319,10 +327,10 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
assert
(
cfg
!=
NULL
);
if
(
cfg
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
if
(
strcasecmp
(
pStr
,
TAOS_SOCKET_TYPE_NAME_UDP
)
!=
0
&&
strcasecmp
(
pStr
,
TAOS_SOCKET_TYPE_NAME_TCP
)
!=
0
)
{
tscError
(
"only 'tcp' or 'udp' allowed for configuring the socket type"
);
return
-
1
;
}
//
if (strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_UDP) != 0 && strcasecmp(pStr, TAOS_SOCKET_TYPE_NAME_TCP) != 0) {
//
tscError("only 'tcp' or 'udp' allowed for configuring the socket type");
//
return -1;
//
}
strncpy
(
tsSocketType
,
pStr
,
tListLen
(
tsSocketType
));
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
...
...
src/dnode/src/dnodeModule.c
浏览文件 @
d43c0ab2
...
...
@@ -121,10 +121,6 @@ void dnodeStartModulesImp() {
}
}
}
if
(
tsModule
[
TSDB_MOD_MGMT
].
num
!=
0
&&
tsModule
[
TSDB_MOD_MGMT
].
cleanUpFp
)
{
(
*
tsModule
[
TSDB_MOD_MGMT
].
cleanUpFp
)();
}
}
void
(
*
dnodeStartModules
)()
=
dnodeStartModulesImp
;
src/dnode/src/dnodeShell.c
浏览文件 @
d43c0ab2
...
...
@@ -85,7 +85,7 @@ int32_t dnodeInitShell() {
rpcInit
.
numOfThreads
=
numOfThreads
;
rpcInit
.
cfp
=
dnodeProcessMsgFromShell
;
rpcInit
.
sessions
=
TSDB_SESSIONS_PER_DNODE
;
rpcInit
.
connType
=
TAOS_CONN_S
OCKET_TYPE_S
()
;
rpcInit
.
connType
=
TAOS_CONN_S
ERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
2000
;
tsDnodeShellServer
=
rpcOpen
(
&
rpcInit
);
...
...
src/inc/trpc.h
浏览文件 @
d43c0ab2
...
...
@@ -39,7 +39,7 @@ typedef struct {
uint32_t
clientIp
;
uint16_t
clientPort
;
uint32_t
serverIp
;
char
*
user
;
char
user
[
TSDB_USER_LEN
]
;
}
SRpcConnInfo
;
typedef
struct
{
...
...
src/kit/shell/src/shellMain.c
浏览文件 @
d43c0ab2
...
...
@@ -81,6 +81,10 @@ struct arguments args = {
*/
int
main
(
int
argc
,
char
*
argv
[])
{
/*setlocale(LC_ALL, "en_US.UTF-8"); */
//
void
*
taos
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
printf
(
"ok
\n
"
);
//
if
(
!
checkVersion
())
{
exit
(
EXIT_FAILURE
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
d43c0ab2
...
...
@@ -87,15 +87,17 @@ int32_t mgmtInitShell() {
int32_t
numOfThreads
=
tsNumOfCores
*
tsNumOfThreadsPerCore
/
4
.
0
;
if
(
numOfThreads
<
1
)
numOfThreads
=
1
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
//TODO
numOfThreads
=
1
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
rpcInit
.
localIp
=
tsAnyIp
?
"0.0.0.0"
:
tsPrivateIp
;;
rpcInit
.
localPort
=
tsMgmtShellPort
;
rpcInit
.
label
=
"MND-shell"
;
rpcInit
.
numOfThreads
=
numOfThreads
;
rpcInit
.
cfp
=
mgmtProcessMsgFromShell
;
rpcInit
.
sessions
=
tsMaxShellConns
;
rpcInit
.
connType
=
TAOS_CONN_S
OCKET_TYPE_S
()
;
rpcInit
.
connType
=
TAOS_CONN_S
ERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
2000
;
rpcInit
.
afp
=
mgmtRetriveUserAuthInfo
;
...
...
@@ -1237,17 +1239,17 @@ int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secr
return
TSDB_CODE_INVALID_USER
;
}
*
spi
=
1
;
*
spi
=
0
;
*
encrypt
=
0
;
*
ckey
=
0
;
memcpy
(
secret
,
pUser
->
pass
,
TSDB_KEY_LEN
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtProcessConnectMsg
(
void
*
pCont
,
int32_t
contLen
,
void
*
a
handle
)
{
static
int32_t
mgmtProcessConnectMsg
(
void
*
pCont
,
int32_t
contLen
,
void
*
t
handle
)
{
SCMConnectMsg
*
pConnectMsg
=
(
SCMConnectMsg
*
)
pCont
;
SRpcConnInfo
connInfo
;
rpcGetConnInfo
(
a
handle
,
&
connInfo
);
rpcGetConnInfo
(
t
handle
,
&
connInfo
);
int32_t
code
;
SUserObj
*
pUser
=
mgmtGetUser
(
connInfo
.
user
);
...
...
@@ -1311,17 +1313,15 @@ static int32_t mgmtProcessConnectMsg(void *pCont, int32_t contLen, void *ahandle
connect_over:
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mLError
(
"user:%s login from %s, code:%d"
,
connInfo
.
user
,
taosIpStr
(
connInfo
.
clientIp
),
code
);
rpcSendResponse
(
a
handle
,
code
,
NULL
,
0
);
rpcSendResponse
(
t
handle
,
code
,
NULL
,
0
);
}
else
{
mLPrint
(
"user:%s login from %s, code:%d"
,
connInfo
.
user
,
taosIpStr
(
connInfo
.
clientIp
),
code
);
rpcSendResponse
(
ahandle
,
code
,
pConnectRsp
,
sizeof
(
p
ConnectRsp
));
rpcSendResponse
(
thandle
,
code
,
pConnectRsp
,
sizeof
(
SCM
ConnectRsp
));
}
rpcFreeCont
(
pCont
);
return
code
;
}
/**
* check if we need to add mgmtProcessMeterMetaMsg into tranQueue, which will be executed one-by-one.
*/
...
...
@@ -1354,6 +1354,7 @@ static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *a
if
(
sdbGetRunStatus
()
!=
SDB_STATUS_SERVING
)
{
mTrace
(
"shell msg is ignored since SDB is not ready"
);
rpcSendResponse
(
ahandle
,
TSDB_CODE_NOT_READY
,
NULL
,
0
);
rpcFreeCont
(
pCont
);
return
;
}
...
...
@@ -1366,6 +1367,7 @@ static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *a
mError
(
"%s from shell is not processed"
,
taosMsg
[(
int8_t
)
type
]);
}
}
rpcFreeCont
(
pCont
);
}
void
mgmtInitProcessShellMsg
()
{
...
...
src/plugins/monitor/src/monitorSystem.c
浏览文件 @
d43c0ab2
...
...
@@ -216,7 +216,8 @@ void monitorInitDatabaseCb(void *param, TAOS_RES *result, int code) {
if
(
-
code
==
TSDB_CODE_TABLE_ALREADY_EXIST
||
-
code
==
TSDB_CODE_DB_ALREADY_EXIST
||
code
>=
0
)
{
monitorTrace
(
"monitor:%p, sql success, code:%d, %s"
,
monitor
->
conn
,
code
,
monitor
->
sql
);
if
(
monitor
->
cmdIndex
==
MONITOR_CMD_CREATE_TB_LOG
)
{
taosLogFp
=
monitorSaveLog
;
//TODO
//taosLogFp = monitorSaveLog;
taosLogSqlFp
=
monitorExecuteSQL
;
taosLogAcctFp
=
monitorSaveAcctLog
;
monitorLPrint
(
"dnode:%s is started"
,
tsPrivateIp
);
...
...
src/rpc/src/rpcMain.c
浏览文件 @
d43c0ab2
...
...
@@ -796,6 +796,7 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) {
}
static
void
rpcProcessIncomingMsg
(
SRpcConn
*
pConn
,
SRpcHead
*
pHead
)
{
SRpcInfo
*
pRpc
=
pConn
->
pRpc
;
pHead
=
rpcDecompressRpcMsg
(
pHead
);
...
...
src/sdb/src/sdbEngine.c
浏览文件 @
d43c0ab2
...
...
@@ -59,6 +59,10 @@ int64_t sdbGetVersion() {
};
int32_t
sdbGetRunStatus
()
{
if
(
!
tsIsCluster
)
{
return
SDB_STATUS_SERVING
;
}
if
(
sdbInited
==
NULL
)
{
return
SDB_STATUS_OFFLINE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录