Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fc22eb44
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc22eb44
编写于
2月 18, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rearrange the code to make it more readable
上级
37b55ef1
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
388 addition
and
382 deletion
+388
-382
src/inc/trpc.h
src/inc/trpc.h
+2
-1
src/rpc/inc/tconncache.h
src/rpc/inc/tconncache.h
+5
-8
src/rpc/src/tconncache.c
src/rpc/src/tconncache.c
+6
-11
src/rpc/src/trpc.c
src/rpc/src/trpc.c
+375
-362
未找到文件。
src/inc/trpc.h
浏览文件 @
fc22eb44
...
@@ -59,7 +59,8 @@ typedef struct {
...
@@ -59,7 +59,8 @@ typedef struct {
int16_t
index
;
int16_t
index
;
int16_t
numOfIps
;
int16_t
numOfIps
;
uint16_t
port
;
uint16_t
port
;
char
ipStr
[
TSDB_MAX_MPEERS
][
40
];
uint32_t
ip
[
TSDB_MAX_MPEERS
];
char
ipStr
[
TSDB_MAX_MPEERS
][
TSDB_IPv4ADDR_LEN
];
}
SRpcIpSet
;
}
SRpcIpSet
;
void
*
rpcOpen
(
SRpcInit
*
pRpc
);
void
*
rpcOpen
(
SRpcInit
*
pRpc
);
...
...
src/rpc/inc/tcache.h
→
src/rpc/inc/tc
onnc
ache.h
浏览文件 @
fc22eb44
...
@@ -13,23 +13,20 @@
...
@@ -13,23 +13,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef TDENGINE_
TSC
CACHE_H
#ifndef TDENGINE_
CONN_
CACHE_H
#define TDENGINE_
TSC
CACHE_H
#define TDENGINE_
CONN_
CACHE_H
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
void
*
taosOpenConnCache
(
int
maxSessions
,
void
(
*
cleanFp
)(
void
*
),
void
*
tmrCtrl
,
int64_t
keepTimer
);
void
*
taosOpenConnCache
(
int
maxSessions
,
void
(
*
cleanFp
)(
void
*
),
void
*
tmrCtrl
,
int64_t
keepTimer
);
void
taosCloseConnCache
(
void
*
handle
);
void
taosCloseConnCache
(
void
*
handle
);
void
taosAddConnIntoCache
(
void
*
handle
,
void
*
data
,
uint32_t
ip
,
uint16_t
port
,
char
*
user
);
void
*
taosAddConnIntoCache
(
void
*
handle
,
void
*
data
,
uint32_t
ip
,
uint16_t
port
,
char
*
user
);
void
*
taosGetConnFromCache
(
void
*
handle
,
uint32_t
ip
,
uint16_t
port
,
char
*
user
);
void
*
taosGetConnFromCache
(
void
*
handle
,
uint32_t
ip
,
uint16_t
port
,
char
*
user
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif // TDENGINE_
TS
CACHE_H
#endif // TDENGINE_
CONN_
CACHE_H
src/rpc/src/tcache.c
→
src/rpc/src/tc
onnc
ache.c
浏览文件 @
fc22eb44
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include "ttime.h"
#include "ttime.h"
#include "ttimer.h"
#include "ttimer.h"
#include "tutil.h"
#include "tutil.h"
#include "tcache.h"
#include "tc
onnc
ache.h"
typedef
struct
_c_hash_t
{
typedef
struct
_c_hash_t
{
uint32_t
ip
;
uint32_t
ip
;
...
@@ -64,7 +64,6 @@ int taosHashConn(void *handle, uint32_t ip, uint16_t port, char *user) {
...
@@ -64,7 +64,6 @@ int taosHashConn(void *handle, uint32_t ip, uint16_t port, char *user) {
}
}
void
taosRemoveExpiredNodes
(
SConnCache
*
pObj
,
SConnHash
*
pNode
,
int
hash
,
uint64_t
time
)
{
void
taosRemoveExpiredNodes
(
SConnCache
*
pObj
,
SConnHash
*
pNode
,
int
hash
,
uint64_t
time
)
{
if
(
pNode
==
NULL
)
return
;
if
(
time
<
pObj
->
keepTimer
+
pNode
->
time
)
return
;
if
(
time
<
pObj
->
keepTimer
+
pNode
->
time
)
return
;
SConnHash
*
pPrev
=
pNode
->
prev
,
*
pNext
;
SConnHash
*
pPrev
=
pNode
->
prev
,
*
pNext
;
...
@@ -86,7 +85,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
...
@@ -86,7 +85,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
pObj
->
connHashList
[
hash
]
=
NULL
;
pObj
->
connHashList
[
hash
]
=
NULL
;
}
}
void
*
taosAddConnIntoCache
(
void
*
handle
,
void
*
data
,
uint32_t
ip
,
uint16_t
port
,
char
*
user
)
{
void
taosAddConnIntoCache
(
void
*
handle
,
void
*
data
,
uint32_t
ip
,
uint16_t
port
,
char
*
user
)
{
int
hash
;
int
hash
;
SConnHash
*
pNode
;
SConnHash
*
pNode
;
SConnCache
*
pObj
;
SConnCache
*
pObj
;
...
@@ -94,12 +93,8 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port,
...
@@ -94,12 +93,8 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port,
uint64_t
time
=
taosGetTimestampMs
();
uint64_t
time
=
taosGetTimestampMs
();
pObj
=
(
SConnCache
*
)
handle
;
pObj
=
(
SConnCache
*
)
handle
;
if
(
pObj
==
NULL
||
pObj
->
maxSessions
==
0
)
return
NULL
;
assert
(
pObj
);
assert
(
data
);
if
(
data
==
NULL
)
{
tscTrace
(
"data:%p ip:%p:%d not valid, not added in cache"
,
data
,
ip
,
port
);
return
NULL
;
}
hash
=
taosHashConn
(
pObj
,
ip
,
port
,
user
);
hash
=
taosHashConn
(
pObj
,
ip
,
port
,
user
);
pNode
=
(
SConnHash
*
)
taosMemPoolMalloc
(
pObj
->
connHashMemPool
);
pNode
=
(
SConnHash
*
)
taosMemPoolMalloc
(
pObj
->
connHashMemPool
);
...
@@ -123,7 +118,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port,
...
@@ -123,7 +118,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port,
tscTrace
(
"%p ip:0x%x:%hu:%d:%p added, connections in cache:%d"
,
data
,
ip
,
port
,
hash
,
pNode
,
pObj
->
count
[
hash
]);
tscTrace
(
"%p ip:0x%x:%hu:%d:%p added, connections in cache:%d"
,
data
,
ip
,
port
,
hash
,
pNode
,
pObj
->
count
[
hash
]);
return
pObj
;
return
;
}
}
void
taosCleanConnCache
(
void
*
handle
,
void
*
tmrId
)
{
void
taosCleanConnCache
(
void
*
handle
,
void
*
tmrId
)
{
...
@@ -155,7 +150,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user)
...
@@ -155,7 +150,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user)
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
pObj
=
(
SConnCache
*
)
handle
;
pObj
=
(
SConnCache
*
)
handle
;
if
(
pObj
==
NULL
||
pObj
->
maxSessions
==
0
)
return
NULL
;
assert
(
pObj
);
uint64_t
time
=
taosGetTimestampMs
();
uint64_t
time
=
taosGetTimestampMs
();
...
...
src/rpc/src/trpc.c
浏览文件 @
fc22eb44
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录