Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
8a416ca4
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,发现更多精彩内容 >>
提交
8a416ca4
编写于
10月 27, 2014
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added a function to get slave name for logs.
上级
a27befc4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
15 deletion
+29
-15
src/networking.c
src/networking.c
+2
-6
src/redis.h
src/redis.h
+1
-0
src/replication.c
src/replication.c
+26
-9
未找到文件。
src/networking.c
浏览文件 @
8a416ca4
...
@@ -678,12 +678,8 @@ void freeClient(redisClient *c) {
...
@@ -678,12 +678,8 @@ void freeClient(redisClient *c) {
/* Log link disconnection with slave */
/* Log link disconnection with slave */
if
((
c
->
flags
&
REDIS_SLAVE
)
&&
!
(
c
->
flags
&
REDIS_MONITOR
))
{
if
((
c
->
flags
&
REDIS_SLAVE
)
&&
!
(
c
->
flags
&
REDIS_MONITOR
))
{
char
ip
[
REDIS_IP_STR_LEN
];
redisLog
(
REDIS_WARNING
,
"Connection with slave %s lost."
,
replicationGetSlaveName
(
c
));
if
(
anetPeerToString
(
c
->
fd
,
ip
,
sizeof
(
ip
),
NULL
)
!=
-
1
)
{
redisLog
(
REDIS_WARNING
,
"Connection with slave %s:%d lost."
,
ip
,
c
->
slave_listening_port
);
}
}
}
/* Free the query buffer */
/* Free the query buffer */
...
...
src/redis.h
浏览文件 @
8a416ca4
...
@@ -1162,6 +1162,7 @@ void unblockClientWaitingReplicas(redisClient *c);
...
@@ -1162,6 +1162,7 @@ void unblockClientWaitingReplicas(redisClient *c);
int
replicationCountAcksByOffset
(
long
long
offset
);
int
replicationCountAcksByOffset
(
long
long
offset
);
void
replicationSendNewlineToMaster
(
void
);
void
replicationSendNewlineToMaster
(
void
);
long
long
replicationGetSlaveOffset
(
void
);
long
long
replicationGetSlaveOffset
(
void
);
char
*
replicationGetSlaveName
(
redisClient
*
c
);
/* Generic persistence functions */
/* Generic persistence functions */
void
startLoading
(
FILE
*
fp
);
void
startLoading
(
FILE
*
fp
);
...
...
src/replication.c
浏览文件 @
8a416ca4
...
@@ -41,6 +41,30 @@ void replicationDiscardCachedMaster(void);
...
@@ -41,6 +41,30 @@ void replicationDiscardCachedMaster(void);
void
replicationResurrectCachedMaster
(
int
newfd
);
void
replicationResurrectCachedMaster
(
int
newfd
);
void
replicationSendAck
(
void
);
void
replicationSendAck
(
void
);
/* --------------------------- Utility functions ---------------------------- */
/* Return the pointer to a string representing the slave ip:listening_port
* pair. Mostly useful for logging, since we want to log a slave using its
* IP address and it's listening port which is more clear for the user, for
* example: "Closing connection with slave 10.1.2.3:6380". */
char
*
replicationGetSlaveName
(
redisClient
*
c
)
{
static
char
buf
[
REDIS_PEER_ID_LEN
];
char
ip
[
REDIS_IP_STR_LEN
];
ip
[
0
]
=
'\0'
;
buf
[
0
]
=
'\0'
;
if
(
anetPeerToString
(
c
->
fd
,
ip
,
sizeof
(
ip
),
NULL
)
!=
-
1
)
{
if
(
c
->
slave_listening_port
)
snprintf
(
buf
,
sizeof
(
buf
),
"%s:%d"
,
ip
,
c
->
slave_listening_port
);
else
snprintf
(
buf
,
sizeof
(
buf
),
"%s:<unknown-slave-port>"
,
ip
);
}
else
{
snprintf
(
buf
,
sizeof
(
buf
),
"client id #%llu"
,
(
unsigned
long
long
)
c
->
id
);
}
return
buf
;
}
/* ---------------------------------- MASTER -------------------------------- */
/* ---------------------------------- MASTER -------------------------------- */
void
createReplicationBacklog
(
void
)
{
void
createReplicationBacklog
(
void
)
{
...
@@ -1973,15 +1997,8 @@ void replicationCron(void) {
...
@@ -1973,15 +1997,8 @@ void replicationCron(void) {
if
(
slave
->
flags
&
REDIS_PRE_PSYNC
)
continue
;
if
(
slave
->
flags
&
REDIS_PRE_PSYNC
)
continue
;
if
((
server
.
unixtime
-
slave
->
repl_ack_time
)
>
server
.
repl_timeout
)
if
((
server
.
unixtime
-
slave
->
repl_ack_time
)
>
server
.
repl_timeout
)
{
{
char
ip
[
REDIS_IP_STR_LEN
];
redisLog
(
REDIS_WARNING
,
"Disconnecting timedout slave: %s"
,
int
port
;
replicationGetSlaveName
(
slave
));
if
(
anetPeerToString
(
slave
->
fd
,
ip
,
sizeof
(
ip
),
&
port
)
!=
-
1
)
{
redisLog
(
REDIS_WARNING
,
"Disconnecting timedout slave: %s:%d"
,
ip
,
slave
->
slave_listening_port
);
}
freeClient
(
slave
);
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录