Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c2a01bfd
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
c2a01bfd
编写于
2月 23, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sync io
上级
0e0af1de
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
6 deletion
+44
-6
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+25
-4
source/libs/sync/test/syncTest.cpp
source/libs/sync/test/syncTest.cpp
+19
-2
未找到文件。
source/libs/sync/src/syncIO.c
浏览文件 @
c2a01bfd
...
...
@@ -14,7 +14,10 @@
*/
#include "syncIO.h"
#include <tep.h>
#include "syncOnMessage.h"
#include "tglobal.h"
#include "tutil.h"
void
*
syncConsumer
(
void
*
param
)
{
SSyncIO
*
io
=
param
;
...
...
@@ -32,7 +35,7 @@ void *syncConsumer(void *param) {
for
(
int
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
qall
,
(
void
**
)
&
pRpcMsg
);
sDebug
(
"sync-io recv
msg: %s"
,
(
char
*
)(
pRpcMsg
->
pCont
));
sDebug
(
"sync-io recv
type:%d msg:%s"
,
pRpcMsg
->
msgType
,
(
char
*
)(
pRpcMsg
->
pCont
));
}
taosResetQitems
(
qall
);
...
...
@@ -109,6 +112,8 @@ SSyncIO *syncIOCreate() {
static
int32_t
syncIOStart
(
SSyncIO
*
io
)
{
taosBlockSIGPIPE
();
tsRpcForceTcp
=
1
;
// cient rpc init
{
SRpcInit
rpcInit
;
...
...
@@ -122,7 +127,7 @@ static int32_t syncIOStart(SSyncIO *io) {
rpcInit
.
user
=
"sync-io"
;
rpcInit
.
secret
=
"sync-io"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
spi
=
1
;
rpcInit
.
spi
=
0
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
io
->
clientRpc
=
rpcOpen
(
&
rpcInit
);
...
...
@@ -155,7 +160,7 @@ static int32_t syncIOStart(SSyncIO *io) {
// start consumer thread
{
if
(
pthread_create
(
&
io
->
tid
,
NULL
,
syncConsumer
,
NULL
)
!=
0
)
{
if
(
pthread_create
(
&
io
->
tid
,
NULL
,
syncConsumer
,
io
)
!=
0
)
{
sError
(
"failed to create sync consumer thread since %s"
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -171,7 +176,23 @@ static int32_t syncIOStop(SSyncIO *io) {
return
0
;
}
static
int32_t
syncIOPing
(
SSyncIO
*
io
)
{
return
0
;
}
static
int32_t
syncIOPing
(
SSyncIO
*
io
)
{
SRpcMsg
rpcMsg
,
rspMsg
;
rpcMsg
.
pCont
=
rpcMallocCont
(
10
);
snprintf
(
rpcMsg
.
pCont
,
10
,
"ping"
);
rpcMsg
.
contLen
=
10
;
rpcMsg
.
handle
=
io
;
rpcMsg
.
msgType
=
1
;
SEpSet
epSet
;
epSet
.
inUse
=
0
;
addEpIntoEpSet
(
&
epSet
,
"127.0.0.1"
,
38000
);
rpcSendRequest
(
io
->
clientRpc
,
&
epSet
,
&
rpcMsg
,
NULL
);
return
0
;
}
static
int32_t
syncIOOnMessage
(
struct
SSyncIO
*
io
,
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
return
0
;
}
...
...
source/libs/sync/test/syncTest.cpp
浏览文件 @
c2a01bfd
...
...
@@ -2,9 +2,19 @@
#include "syncIO.h"
#include "syncInt.h"
void
*
pingFunc
(
void
*
param
)
{
SSyncIO
*
io
=
(
SSyncIO
*
)
param
;
while
(
1
)
{
sDebug
(
"io->ping"
);
io
->
ping
(
io
);
sleep
(
1
);
}
return
NULL
;
}
int
main
()
{
tsAsyncLog
=
0
;
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
taosInitLog
((
char
*
)
"syncTest.log"
,
100000
,
10
);
sDebug
(
"sync test"
);
syncStartEnv
();
...
...
@@ -12,8 +22,15 @@ int main() {
SSyncIO
*
syncIO
=
syncIOCreate
();
assert
(
syncIO
!=
NULL
);
syncIO
->
start
(
syncIO
);
sleep
(
2
);
pthread_t
tid
;
pthread_create
(
&
tid
,
NULL
,
pingFunc
,
syncIO
);
while
(
1
)
{
sleep
(
3
);
sleep
(
1
);
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录