Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
62ec599c
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
62ec599c
编写于
11月 04, 2010
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
typos and minor stuff fixed in the new non blocking replication code
上级
f4aa600b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
10 deletion
+13
-10
src/redis.c
src/redis.c
+1
-1
src/redis.h
src/redis.h
+2
-2
src/replication.c
src/replication.c
+10
-7
未找到文件。
src/redis.c
浏览文件 @
62ec599c
...
...
@@ -635,7 +635,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* Replication cron function -- used to reconnect to master and
* to detect transfer failures. */
if
(
!
(
loops
%
10
))
replicationCron
(
void
);
if
(
!
(
loops
%
10
))
replicationCron
();
return
100
;
}
...
...
src/redis.h
浏览文件 @
62ec599c
...
...
@@ -152,7 +152,7 @@
/* Slave replication state - slave side */
#define REDIS_REPL_NONE 0
/* No active replication */
#define REDIS_REPL_CONNECT 1
/* Must connect to master */
#define REDIS_REPL_TRANFER 2
/* Receiving .rdb from master */
#define REDIS_REPL_TRAN
S
FER 2
/* Receiving .rdb from master */
#define REDIS_REPL_CONNECTED 3
/* Connected to master */
/* Slave replication state - from the point of view of master
...
...
@@ -408,7 +408,7 @@ struct redisServer {
int
masterport
;
redisClient
*
master
;
/* client that is master for this slave */
int
replstate
;
/* replication status if the instance is a slave */
off_t
repl_transfer_left
;
/* bytes left reading .rdb
if this is a slave
*/
off_t
repl_transfer_left
;
/* bytes left reading .rdb */
int
repl_transfer_s
;
/* slave -> master SYNC socket */
int
repl_transfer_fd
;
/* slave -> master SYNC temp file descriptor */
char
*
repl_transfer_tmpfile
;
/* slave-> master SYNC temp file name */
...
...
src/replication.c
浏览文件 @
62ec599c
...
...
@@ -306,11 +306,14 @@ void replicationAbortSyncTransfer(void) {
/* Asynchronously read the SYNC payload we receive from a master */
void
readSyncBulkPayload
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
unsigned
char
buf
[
4096
]
size_t
nread
,
readlen
;
unsigned
char
buf
[
4096
];
ssize_t
nread
,
readlen
;
REDIS_NOTUSED
(
el
);
REDIS_NOTUSED
(
privdata
);
REDIS_NOTUSED
(
mask
);
readlen
=
(
server
.
repl_transfer_left
<
sizeof
(
buf
))
?
server
.
repl_transfer_left
:
sizeof
(
buf
);
readlen
=
(
server
.
repl_transfer_left
<
(
signed
)
sizeof
(
buf
))
?
server
.
repl_transfer_left
:
(
signed
)
sizeof
(
buf
);
nread
=
read
(
fd
,
buf
,
readlen
);
if
(
nread
<=
0
)
{
redisLog
(
REDIS_WARNING
,
"I/O error trying to sync with MASTER: %s"
,
...
...
@@ -425,8 +428,8 @@ int syncWithMaster(void) {
}
/* Setup the non blocking download of the bulk file. */
if
(
aeCreateFileEvent
(
server
.
el
,
fd
,
AE_READABLE
,
readSyncBulkPayload
)
==
AE_ERR
)
if
(
aeCreateFileEvent
(
server
.
el
,
fd
,
AE_READABLE
,
readSyncBulkPayload
,
NULL
)
==
AE_ERR
)
{
close
(
fd
);
redisLog
(
REDIS_WARNING
,
"Can't create readable event for SYNC"
);
...
...
@@ -481,7 +484,7 @@ void replicationCron(void) {
}
/* Check if we should connect to a MASTER */
if
(
server
.
replstate
==
REDIS_REPL_CONNECT
&&
!
(
loops
%
10
)
)
{
if
(
server
.
replstate
==
REDIS_REPL_CONNECT
)
{
redisLog
(
REDIS_NOTICE
,
"Connecting to MASTER..."
);
if
(
syncWithMaster
()
==
REDIS_OK
)
{
redisLog
(
REDIS_NOTICE
,
"MASTER <-> SLAVE sync succeeded"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录