Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a3bb1d5f
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看板
提交
a3bb1d5f
编写于
6月 20, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tune the code
上级
e90d241e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
39 addition
and
20 deletion
+39
-20
src/rpc/inc/rpcTcp.h
src/rpc/inc/rpcTcp.h
+1
-0
src/rpc/inc/rpcUdp.h
src/rpc/inc/rpcUdp.h
+1
-0
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+9
-15
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+11
-3
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+17
-2
未找到文件。
src/rpc/inc/rpcTcp.h
浏览文件 @
a3bb1d5f
...
...
@@ -25,6 +25,7 @@ void taosStopTcpServer(void *param);
void
taosCleanUpTcpServer
(
void
*
param
);
void
*
taosInitTcpClient
(
uint32_t
ip
,
uint16_t
port
,
char
*
label
,
int
num
,
void
*
fp
,
void
*
shandle
);
void
taosStopTcpClient
(
void
*
chandle
);
void
taosCleanUpTcpClient
(
void
*
chandle
);
void
*
taosOpenTcpClientConnection
(
void
*
shandle
,
void
*
thandle
,
uint32_t
ip
,
uint16_t
port
);
...
...
src/rpc/inc/rpcUdp.h
浏览文件 @
a3bb1d5f
...
...
@@ -23,6 +23,7 @@ extern "C" {
#include "taosdef.h"
void
*
taosInitUdpConnection
(
uint32_t
ip
,
uint16_t
port
,
char
*
label
,
int
,
void
*
fp
,
void
*
shandle
);
void
taosStopUdpConnection
(
void
*
handle
);
void
taosCleanUpUdpConnection
(
void
*
handle
);
int
taosSendUdpData
(
uint32_t
ip
,
uint16_t
port
,
void
*
data
,
int
dataLen
,
void
*
chandle
);
void
*
taosOpenUdpConnection
(
void
*
shandle
,
void
*
thandle
,
uint32_t
ip
,
uint16_t
port
);
...
...
src/rpc/src/rpcMain.c
浏览文件 @
a3bb1d5f
...
...
@@ -147,17 +147,17 @@ void *(*taosInitConn[])(uint32_t ip, uint16_t port, char *label, int threads, vo
};
void
(
*
taosCleanUpConn
[])(
void
*
thandle
)
=
{
NULL
,
NULL
,
taosCleanUpUdpConnection
,
taosCleanUpUdpConnection
,
taosCleanUpTcpServer
,
taosCleanUpTcpClient
};
void
(
*
taosStopConn
[])(
void
*
thandle
)
=
{
taos
CleanU
pUdpConnection
,
taos
CleanU
pUdpConnection
,
taos
Sto
pUdpConnection
,
taos
Sto
pUdpConnection
,
taosStopTcpServer
,
NULL
taosStopTcpClient
,
};
int
(
*
taosSendData
[])(
uint32_t
ip
,
uint16_t
port
,
void
*
data
,
int
len
,
void
*
chandle
)
=
{
...
...
@@ -297,11 +297,8 @@ void rpcClose(void *param) {
SRpcInfo
*
pRpc
=
(
SRpcInfo
*
)
param
;
// stop connection to outside first
if
(
taosStopConn
[
pRpc
->
connType
|
RPC_CONN_TCP
])
(
*
taosStopConn
[
pRpc
->
connType
|
RPC_CONN_TCP
])(
pRpc
->
tcphandle
);
if
(
taosStopConn
[
pRpc
->
connType
])
(
*
taosStopConn
[
pRpc
->
connType
])(
pRpc
->
udphandle
);
(
*
taosStopConn
[
pRpc
->
connType
|
RPC_CONN_TCP
])(
pRpc
->
tcphandle
);
(
*
taosStopConn
[
pRpc
->
connType
])(
pRpc
->
udphandle
);
// close all connections
for
(
int
i
=
0
;
i
<
pRpc
->
sessions
;
++
i
)
{
...
...
@@ -311,11 +308,8 @@ void rpcClose(void *param) {
}
// clean up
if
(
taosCleanUpConn
[
pRpc
->
connType
|
RPC_CONN_TCP
])
(
*
taosCleanUpConn
[
pRpc
->
connType
|
RPC_CONN_TCP
])(
pRpc
->
tcphandle
);
if
(
taosCleanUpConn
[
pRpc
->
connType
])
(
*
taosCleanUpConn
[
pRpc
->
connType
])(
pRpc
->
udphandle
);
(
*
taosCleanUpConn
[
pRpc
->
connType
|
RPC_CONN_TCP
])(
pRpc
->
tcphandle
);
(
*
taosCleanUpConn
[
pRpc
->
connType
])(
pRpc
->
udphandle
);
tTrace
(
"%s rpc is closed"
,
pRpc
->
label
);
rpcDecRef
(
pRpc
);
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
a3bb1d5f
...
...
@@ -193,10 +193,11 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
void
taosStopTcpServer
(
void
*
handle
)
{
SServerObj
*
pServerObj
=
handle
;
tTrace
(
"TCP:%s, stop accept new connections"
,
pServerObj
->
label
);
if
(
pServerObj
==
NULL
)
return
;
if
(
pServerObj
->
fd
>=
0
)
shutdown
(
pServerObj
->
fd
,
SHUT_RD
);
if
(
pServerObj
->
thread
)
pthread_join
(
pServerObj
->
thread
,
NULL
);
tTrace
(
"%s TCP server is stopped"
,
pServerObj
->
label
);
}
void
taosCleanUpTcpServer
(
void
*
handle
)
{
...
...
@@ -210,7 +211,7 @@ void taosCleanUpTcpServer(void *handle) {
pthread_mutex_destroy
(
&
(
pThreadObj
->
mutex
));
}
tTrace
(
"
TCP:%s,
TCP server is cleaned up"
,
pServerObj
->
label
);
tTrace
(
"
%s
TCP server is cleaned up"
,
pServerObj
->
label
);
tfree
(
pServerObj
->
pThreadObj
);
tfree
(
pServerObj
);
...
...
@@ -309,12 +310,19 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
return
pThreadObj
;
}
void
taosStopTcpClient
(
void
*
chandle
)
{
SThreadObj
*
pThreadObj
=
chandle
;
if
(
pThreadObj
==
NULL
)
return
;
tTrace
(
"%s TCP client is stopped"
,
pThreadObj
->
label
);
}
void
taosCleanUpTcpClient
(
void
*
chandle
)
{
SThreadObj
*
pThreadObj
=
chandle
;
if
(
pThreadObj
==
NULL
)
return
;
taosStopTcpThread
(
pThreadObj
);
tTrace
(
"%s
, all connections are
cleaned up"
,
pThreadObj
->
label
);
tTrace
(
"%s
TCP client is
cleaned up"
,
pThreadObj
->
label
);
tfree
(
pThreadObj
);
}
...
...
src/rpc/src/rpcUdp.c
浏览文件 @
a3bb1d5f
...
...
@@ -130,7 +130,7 @@ void *taosInitUdpConnection(uint32_t ip, uint16_t port, char *label, int threads
return
pSet
;
}
void
taos
CleanU
pUdpConnection
(
void
*
handle
)
{
void
taos
Sto
pUdpConnection
(
void
*
handle
)
{
SUdpConnSet
*
pSet
=
(
SUdpConnSet
*
)
handle
;
SUdpConn
*
pConn
;
...
...
@@ -146,9 +146,24 @@ void taosCleanUpUdpConnection(void *handle) {
pConn
=
pSet
->
udpConn
+
i
;
if
(
pConn
->
thread
)
pthread_join
(
pConn
->
thread
,
NULL
);
tfree
(
pConn
->
buffer
);
tTrace
(
"%s UDP thread is closed, inedx:%d"
,
pConn
->
label
,
i
);
// tTrace("%s UDP thread is closed, index:%d", pConn->label, i);
}
tTrace
(
"%s UDP is stopped"
,
pSet
->
label
);
}
void
taosCleanUpUdpConnection
(
void
*
handle
)
{
SUdpConnSet
*
pSet
=
(
SUdpConnSet
*
)
handle
;
SUdpConn
*
pConn
;
if
(
pSet
==
NULL
)
return
;
for
(
int
i
=
0
;
i
<
pSet
->
threads
;
++
i
)
{
pConn
=
pSet
->
udpConn
+
i
;
if
(
pConn
->
fd
>=
0
)
taosCloseSocket
(
pConn
->
fd
);
}
tTrace
(
"%s UDP is cleaned up"
,
pSet
->
label
);
tfree
(
pSet
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录