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
83d4311a
Commit
83d4311a
authored
Jul 31, 2018
by
antirez
Browse files
Cluster cron announce IP minor refactoring.
parent
a633f8e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
83d4311a
...
...
@@ -3321,14 +3321,17 @@ void clusterCron(void) {
int
changed
=
0
;
if
(
prev_ip
==
NULL
&&
curr_ip
!=
NULL
)
changed
=
1
;
if
(
prev_ip
!=
NULL
&&
curr_ip
==
NULL
)
changed
=
1
;
if
(
prev_ip
&&
curr_ip
&&
strcmp
(
prev_ip
,
curr_ip
))
changed
=
1
;
else
if
(
prev_ip
!=
NULL
&&
curr_ip
==
NULL
)
changed
=
1
;
else
if
(
prev_ip
&&
curr_ip
&&
strcmp
(
prev_ip
,
curr_ip
))
changed
=
1
;
if
(
changed
)
{
if
(
prev_ip
)
zfree
(
prev_ip
);
prev_ip
=
curr_ip
;
if
(
curr_ip
)
{
/* We always take a copy of the previous IP address, by
* duplicating the string. This way later we can check if
* the address really changed. */
prev_ip
=
zstrdup
(
prev_ip
);
strncpy
(
myself
->
ip
,
server
.
cluster_announce_ip
,
NET_IP_STR_LEN
);
myself
->
ip
[
NET_IP_STR_LEN
-
1
]
=
'\0'
;
...
...
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