Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
93f6cd34
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
93f6cd34
编写于
2月 20, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some bugs
上级
a2629a02
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
13 deletion
+14
-13
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+13
-12
src/rpc/test/rclient.c
src/rpc/test/rclient.c
+1
-1
未找到文件。
src/rpc/src/rpcMain.c
浏览文件 @
93f6cd34
...
@@ -168,7 +168,7 @@ static void rpcSendQuickRsp(SRpcConn *pConn, int32_t code);
...
@@ -168,7 +168,7 @@ static void rpcSendQuickRsp(SRpcConn *pConn, int32_t code);
static
void
rpcSendErrorMsgToPeer
(
SRpcInfo
*
pRpc
,
char
*
pMsg
,
int32_t
code
,
uint32_t
ip
,
uint16_t
port
,
void
*
chandle
);
static
void
rpcSendErrorMsgToPeer
(
SRpcInfo
*
pRpc
,
char
*
pMsg
,
int32_t
code
,
uint32_t
ip
,
uint16_t
port
,
void
*
chandle
);
static
void
rpcSendMsgToPeer
(
SRpcConn
*
pConn
,
void
*
data
,
int
dataLen
);
static
void
rpcSendMsgToPeer
(
SRpcConn
*
pConn
,
void
*
data
,
int
dataLen
);
static
void
*
rpcProcessMsgFromPeer
(
void
*
data
,
int
dataLen
,
uint32_t
ip
,
uint16_t
port
,
void
*
s
handle
,
void
*
chandle
);
static
void
*
rpcProcessMsgFromPeer
(
void
*
msg
,
int
msgLen
,
uint32_t
ip
,
uint16_t
port
,
void
*
shandle
,
void
*
t
handle
,
void
*
chandle
);
static
void
rpcProcessIncomingMsg
(
SRpcConn
*
pConn
,
SRpcHead
*
pHead
);
static
void
rpcProcessIncomingMsg
(
SRpcConn
*
pConn
,
SRpcHead
*
pHead
);
static
void
rpcProcessConnError
(
void
*
param
,
void
*
id
);
static
void
rpcProcessConnError
(
void
*
param
,
void
*
id
);
static
void
rpcProcessRetryTimer
(
void
*
,
void
*
);
static
void
rpcProcessRetryTimer
(
void
*
,
void
*
);
...
@@ -323,14 +323,15 @@ void rpcSendResponse(void *handle, int32_t code, void *pCont, int contLen) {
...
@@ -323,14 +323,15 @@ void rpcSendResponse(void *handle, int32_t code, void *pCont, int contLen) {
int
msgLen
=
0
;
int
msgLen
=
0
;
SRpcConn
*
pConn
=
(
SRpcConn
*
)
handle
;
SRpcConn
*
pConn
=
(
SRpcConn
*
)
handle
;
SRpcInfo
*
pRpc
=
pConn
->
pRpc
;
SRpcInfo
*
pRpc
=
pConn
->
pRpc
;
SRpcHead
*
pHead
=
rpcHeadFromCont
(
pCont
);
char
*
msg
=
(
char
*
)
pHead
;
if
(
pCont
==
NULL
)
{
if
(
pCont
==
NULL
)
{
pCont
=
rpcMallocCont
(
0
);
pCont
=
rpcMallocCont
(
0
);
contLen
=
0
;
contLen
=
0
;
}
}
SRpcHead
*
pHead
=
rpcHeadFromCont
(
pCont
);
char
*
msg
=
(
char
*
)
pHead
;
contLen
=
rpcCompressRpcMsg
(
pCont
,
contLen
);
contLen
=
rpcCompressRpcMsg
(
pCont
,
contLen
);
msgLen
=
rpcMsgLenFromCont
(
contLen
);
msgLen
=
rpcMsgLenFromCont
(
contLen
);
...
@@ -689,17 +690,17 @@ static int32_t rpcProcessHead(SRpcInfo *pRpc, SRpcConn **ppConn, void *data, int
...
@@ -689,17 +690,17 @@ static int32_t rpcProcessHead(SRpcInfo *pRpc, SRpcConn **ppConn, void *data, int
return
code
;
return
code
;
}
}
static
void
*
rpcProcessMsgFromPeer
(
void
*
data
,
int
dataLen
,
uint32_t
ip
,
uint16_t
port
,
void
*
s
handle
,
void
*
chandle
)
{
static
void
*
rpcProcessMsgFromPeer
(
void
*
msg
,
int
msgLen
,
uint32_t
ip
,
uint16_t
port
,
void
*
shandle
,
void
*
t
handle
,
void
*
chandle
)
{
SRpcHead
*
pHead
=
(
SRpcHead
*
)
data
;
SRpcHead
*
pHead
=
(
SRpcHead
*
)
msg
;
SRpcInfo
*
pRpc
=
(
SRpcInfo
*
)
shandle
;
SRpcInfo
*
pRpc
=
(
SRpcInfo
*
)
shandle
;
SRpcConn
*
pConn
=
NULL
;
SRpcConn
*
pConn
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
tDump
(
data
,
data
Len
);
tDump
(
msg
,
msg
Len
);
pthread_mutex_lock
(
&
pRpc
->
mutex
);
pthread_mutex_lock
(
&
pRpc
->
mutex
);
code
=
rpcProcessHead
(
pRpc
,
&
pConn
,
data
,
data
Len
,
ip
);
code
=
rpcProcessHead
(
pRpc
,
&
pConn
,
msg
,
msg
Len
,
ip
);
if
(
pConn
)
{
if
(
pConn
)
{
// update connection info
// update connection info
...
@@ -721,7 +722,7 @@ static void *rpcProcessMsgFromPeer(void *data, int dataLen, uint32_t ip, uint16_
...
@@ -721,7 +722,7 @@ static void *rpcProcessMsgFromPeer(void *data, int dataLen, uint32_t ip, uint16_
if
(
pHead
->
msgType
<
TSDB_MSG_TYPE_HEARTBEAT
||
(
rpcDebugFlag
&
16
))
{
if
(
pHead
->
msgType
<
TSDB_MSG_TYPE_HEARTBEAT
||
(
rpcDebugFlag
&
16
))
{
tTrace
(
"%s pConn:%p, %s received from 0x%x:%hu, parse code:%x len:%d source:0x%08x dest:0x%08x tranId:%d"
,
tTrace
(
"%s pConn:%p, %s received from 0x%x:%hu, parse code:%x len:%d source:0x%08x dest:0x%08x tranId:%d"
,
pRpc
->
label
,
pConn
,
taosMsg
[
pHead
->
msgType
],
ip
,
port
,
code
,
pRpc
->
label
,
pConn
,
taosMsg
[
pHead
->
msgType
],
ip
,
port
,
code
,
data
Len
,
pHead
->
sourceId
,
pHead
->
destId
,
pHead
->
tranId
);
msg
Len
,
pHead
->
sourceId
,
pHead
->
destId
,
pHead
->
tranId
);
}
}
if
(
pConn
&&
pRpc
->
idleTime
)
{
if
(
pConn
&&
pRpc
->
idleTime
)
{
...
@@ -731,7 +732,7 @@ static void *rpcProcessMsgFromPeer(void *data, int dataLen, uint32_t ip, uint16_
...
@@ -731,7 +732,7 @@ static void *rpcProcessMsgFromPeer(void *data, int dataLen, uint32_t ip, uint16_
if
(
code
!=
TSDB_CODE_ALREADY_PROCESSED
)
{
if
(
code
!=
TSDB_CODE_ALREADY_PROCESSED
)
{
if
(
code
!=
0
)
{
// parsing error
if
(
code
!=
0
)
{
// parsing error
if
(
rpcIsReq
(
pHead
->
msgType
)
)
{
if
(
rpcIsReq
(
pHead
->
msgType
)
)
{
rpcSendErrorMsgToPeer
(
pRpc
,
data
,
code
,
ip
,
port
,
chandle
);
rpcSendErrorMsgToPeer
(
pRpc
,
msg
,
code
,
ip
,
port
,
chandle
);
tTrace
(
"%s pConn:%p, %s is sent with error code:%x"
,
pRpc
->
label
,
pConn
,
taosMsg
[
pHead
->
msgType
+
1
],
code
);
tTrace
(
"%s pConn:%p, %s is sent with error code:%x"
,
pRpc
->
label
,
pConn
,
taosMsg
[
pHead
->
msgType
+
1
],
code
);
}
}
}
else
{
// parsing OK
}
else
{
// parsing OK
...
@@ -739,7 +740,7 @@ static void *rpcProcessMsgFromPeer(void *data, int dataLen, uint32_t ip, uint16_
...
@@ -739,7 +740,7 @@ static void *rpcProcessMsgFromPeer(void *data, int dataLen, uint32_t ip, uint16_
}
}
}
}
if
(
code
!=
0
)
free
(
data
);
if
(
code
!=
0
)
free
(
msg
);
return
pConn
;
return
pConn
;
}
}
...
@@ -766,8 +767,8 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
...
@@ -766,8 +767,8 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
rpcSendReqToServer
(
pRpc
,
pContext
);
rpcSendReqToServer
(
pRpc
,
pContext
);
}
else
{
}
else
{
rpcFreeOutMsg
(
rpcHeadFromCont
(
pContext
->
pCont
));
// free the request msg
rpcFreeOutMsg
(
rpcHeadFromCont
(
pContext
->
pCont
));
// free the request msg
if
(
p
Context
->
ipSet
.
index
!=
pContext
->
oldIndex
||
pContext
->
redirect
)
if
(
p
Rpc
->
ufp
&&
(
pContext
->
ipSet
.
index
!=
pContext
->
oldIndex
||
pContext
->
redirect
)
)
(
*
pRpc
->
ufp
)(
pContext
->
ahandle
,
pContext
->
ipSet
);
(
*
pRpc
->
ufp
)(
pContext
->
ahandle
,
pContext
->
ipSet
);
// notify the update of ipSet
(
*
pRpc
->
cfp
)(
pHead
->
msgType
,
pCont
,
contLen
,
pContext
->
ahandle
,
pContext
->
ipSet
.
index
);
(
*
pRpc
->
cfp
)(
pHead
->
msgType
,
pCont
,
contLen
,
pContext
->
ahandle
,
pContext
->
ipSet
.
index
);
}
}
}
}
...
...
src/rpc/test/rclient.c
浏览文件 @
93f6cd34
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include <stdint.h>
#include <stdint.h>
void
processMsg
(
char
type
,
void
*
pCont
,
int
contLen
,
void
*
ahandle
,
int32_t
code
)
{
void
processMsg
(
char
type
,
void
*
pCont
,
int
contLen
,
void
*
ahandle
,
int32_t
code
)
{
dPrint
(
"response is received, type:%d, contLen:%d code:%
d
, ahandle:%p"
,
type
,
contLen
,
code
,
ahandle
);
dPrint
(
"response is received, type:%d, contLen:%d code:%
x
, ahandle:%p"
,
type
,
contLen
,
code
,
ahandle
);
}
}
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录