Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
3ab49895
Commit
3ab49895
authored
May 13, 2015
by
antirez
Browse files
Sentinel: limit reconnection frequency to the ping period
parent
0eb0b55f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
3ab49895
...
@@ -146,6 +146,8 @@ typedef struct instanceLink {
...
@@ -146,6 +146,8 @@ typedef struct instanceLink {
mstime_t
last_pong_time
;
/* Last time the instance replied to ping,
mstime_t
last_pong_time
;
/* Last time the instance replied to ping,
whatever the reply was. That's used to check
whatever the reply was. That's used to check
if the link is idle and must be reconnected. */
if the link is idle and must be reconnected. */
mstime_t
last_reconn_time
;
/* Last reconnection attempt performed when
the link was down. */
}
instanceLink
;
}
instanceLink
;
typedef
struct
sentinelRedisInstance
{
typedef
struct
sentinelRedisInstance
{
...
@@ -921,6 +923,7 @@ instanceLink *createInstanceLink(void) {
...
@@ -921,6 +923,7 @@ instanceLink *createInstanceLink(void) {
link
->
pc
=
NULL
;
link
->
pc
=
NULL
;
link
->
cc_conn_time
=
0
;
link
->
cc_conn_time
=
0
;
link
->
pc_conn_time
=
0
;
link
->
pc_conn_time
=
0
;
link
->
last_reconn_time
=
0
;
link
->
pc_last_activity
=
0
;
link
->
pc_last_activity
=
0
;
/* We set the last_ping_time to "now" even if we actually don't have yet
/* We set the last_ping_time to "now" even if we actually don't have yet
* a connection with the node, nor we sent a ping.
* a connection with the node, nor we sent a ping.
...
@@ -1826,6 +1829,10 @@ void sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char
...
@@ -1826,6 +1829,10 @@ void sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char
void
sentinelReconnectInstance
(
sentinelRedisInstance
*
ri
)
{
void
sentinelReconnectInstance
(
sentinelRedisInstance
*
ri
)
{
if
(
ri
->
link
->
disconnected
==
0
)
return
;
if
(
ri
->
link
->
disconnected
==
0
)
return
;
instanceLink
*
link
=
ri
->
link
;
instanceLink
*
link
=
ri
->
link
;
mstime_t
now
=
mstime
();
if
(
now
-
ri
->
link
->
last_reconn_time
<
SENTINEL_PING_PERIOD
)
return
;
ri
->
link
->
last_reconn_time
=
now
;
/* Commands connection. */
/* Commands connection. */
if
(
link
->
cc
==
NULL
)
{
if
(
link
->
cc
==
NULL
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment