Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
23ede971
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
23ede971
编写于
12月 23, 2020
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2502]<feature>: force version checking with rpc request messages
上级
a0981ed7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
1 deletion
+40
-1
src/common/src/tglobal.c
src/common/src/tglobal.c
+19
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+4
-0
src/rpc/inc/rpcHead.h
src/rpc/inc/rpcHead.h
+3
-0
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+1
-1
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+6
-0
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+7
-0
未找到文件。
src/common/src/tglobal.c
浏览文件 @
23ede971
...
...
@@ -25,6 +25,7 @@
#include "tutil.h"
#include "tlocale.h"
#include "ttimezone.h"
#include "taosmsg.h"
// cluster
char
tsFirst
[
TSDB_EP_LEN
]
=
{
0
};
...
...
@@ -1461,6 +1462,24 @@ int32_t taosCheckGlobalCfg() {
tsVersion
=
10
*
tsVersion
;
taosMsgVer
=
0
;
for
(
int
ver
=
0
,
dotCount
=
0
,
i
=
0
;
i
<
TSDB_VERSION_LEN
;
i
++
)
{
if
(
version
[
i
]
>=
'0'
&&
version
[
i
]
<=
'9'
)
{
ver
=
ver
*
10
+
(
version
[
i
]
-
'0'
);
}
else
if
(
version
[
i
]
==
'.'
)
{
taosMsgVer
|=
ver
&
0xFF
;
taosMsgVer
<<=
8
;
if
(
++
dotCount
>=
3
)
{
break
;
}
ver
=
0
;
}
else
if
(
version
[
i
]
==
0
)
{
break
;
}
}
tsDnodeShellPort
=
tsServerPort
+
TSDB_PORT_DNODESHELL
;
// udp[6035-6039] tcp[6035]
tsDnodeDnodePort
=
tsServerPort
+
TSDB_PORT_DNODEDNODE
;
// udp/tcp
tsSyncPort
=
tsServerPort
+
TSDB_PORT_SYNC
;
...
...
src/inc/taosmsg.h
浏览文件 @
23ede971
...
...
@@ -31,10 +31,14 @@ extern "C" {
// message type
#ifdef TAOS_MESSAGE_C
uint32_t
taosMsgVer
=
0
;
#define TAOS_DEFINE_MESSAGE_TYPE( name, msg ) msg, msg "-rsp",
char
*
taosMsg
[]
=
{
"null"
,
#else
extern
uint32_t
taosMsgVer
;
#define TAOS_DEFINE_MESSAGE_TYPE( name, msg ) name, name##_RSP,
enum
{
TSDB_MESSAGE_NULL
=
0
,
...
...
src/rpc/inc/rpcHead.h
浏览文件 @
23ede971
...
...
@@ -20,6 +20,8 @@
extern
"C"
{
#endif
#define rpcIsReq(type) (type & 1U)
#define RPC_CONN_UDPS 0
#define RPC_CONN_UDPC 1
#define RPC_CONN_TCPS 2
...
...
@@ -58,6 +60,7 @@ typedef struct {
char
empty
[
1
];
// reserved
uint8_t
msgType
;
// message type
int32_t
msgLen
;
// message length including the header iteslf
uint32_t
msgVer
;
int32_t
code
;
// code in response message
uint8_t
content
[
0
];
// message body starts from here
}
SRpcHead
;
...
...
src/rpc/src/rpcMain.c
浏览文件 @
23ede971
...
...
@@ -38,7 +38,6 @@
#define rpcContFromHead(msg) (msg + sizeof(SRpcHead))
#define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead))
#define rpcContLenFromMsg(msgLen) (msgLen - sizeof(SRpcHead))
#define rpcIsReq(type) (type & 1U)
typedef
struct
{
int
sessions
;
// number of sessions allowed
...
...
@@ -1282,6 +1281,7 @@ static void rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) {
// set the message header
pHead
->
version
=
1
;
pHead
->
msgVer
=
htonl
(
taosMsgVer
);
pHead
->
msgType
=
msgType
;
pHead
->
encrypt
=
0
;
pConn
->
tranId
++
;
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
23ede971
...
...
@@ -18,6 +18,7 @@
#include "tutil.h"
#include "taosdef.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "rpcLog.h"
#include "rpcHead.h"
#include "rpcTcp.h"
...
...
@@ -423,6 +424,11 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
return
-
1
;
}
if
(
rpcIsReq
(
rpcHead
.
msgType
)
&&
htonl
(
rpcHead
.
msgVer
)
!=
taosMsgVer
)
{
tError
(
"%s %p FD:%p, client version:%08x mismatched with server version:%08x"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
pFdObj
,
htonl
(
rpcHead
.
msgVer
),
taosMsgVer
);
return
-
1
;
}
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
rpcHead
.
msgLen
);
int32_t
size
=
msgLen
+
tsRpcOverhead
;
buffer
=
malloc
(
size
);
...
...
src/rpc/src/rpcUdp.c
浏览文件 @
23ede971
...
...
@@ -20,6 +20,7 @@
#include "tutil.h"
#include "taosdef.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "rpcLog.h"
#include "rpcUdp.h"
#include "rpcHead.h"
...
...
@@ -209,6 +210,12 @@ static void *taosRecvUdpData(void *param) {
continue
;
}
SRpcHead
*
pRpcHead
=
(
SRpcHead
*
)
msg
;
if
(
rpcIsReq
(
pRpcHead
->
msgType
)
&&
htonl
(
pRpcHead
->
msgVer
)
!=
taosMsgVer
)
{
tError
(
"%s client version:%08x mismatched with server version:%08x"
,
pConn
->
label
,
htonl
(
pRpcHead
->
msgVer
),
taosMsgVer
);
continue
;
}
int32_t
size
=
dataLen
+
tsRpcOverhead
;
char
*
tmsg
=
malloc
(
size
);
if
(
NULL
==
tmsg
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录