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
6ec795d2
Commit
6ec795d2
authored
Sep 25, 2013
by
antirez
Browse files
Cluster: update our currentEpoch when a greater one is seen.
parent
d426ada8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
6ec795d2
...
@@ -873,6 +873,7 @@ int clusterProcessPacket(clusterLink *link) {
...
@@ -873,6 +873,7 @@ int clusterProcessPacket(clusterLink *link) {
uint32_t
totlen
=
ntohl
(
hdr
->
totlen
);
uint32_t
totlen
=
ntohl
(
hdr
->
totlen
);
uint16_t
type
=
ntohs
(
hdr
->
type
);
uint16_t
type
=
ntohs
(
hdr
->
type
);
uint16_t
flags
=
ntohs
(
hdr
->
flags
);
uint16_t
flags
=
ntohs
(
hdr
->
flags
);
uint64_t
senderCurrentEpoch
,
senderConfigEpoch
;
clusterNode
*
sender
;
clusterNode
*
sender
;
redisLog
(
REDIS_DEBUG
,
"--- Processing packet of type %d, %lu bytes"
,
redisLog
(
REDIS_DEBUG
,
"--- Processing packet of type %d, %lu bytes"
,
...
@@ -909,9 +910,17 @@ int clusterProcessPacket(clusterLink *link) {
...
@@ -909,9 +910,17 @@ int clusterProcessPacket(clusterLink *link) {
if
(
totlen
!=
explen
)
return
1
;
if
(
totlen
!=
explen
)
return
1
;
}
}
/* Process packets by type. */
/* Check if the sender is known.
* If it is, update our currentEpoch to its epoch if greater than our. */
sender
=
clusterLookupNode
(
hdr
->
sender
);
sender
=
clusterLookupNode
(
hdr
->
sender
);
if
(
sender
&&
!
(
sender
->
flags
&
REDIS_NODE_HANDSHAKE
))
{
senderCurrentEpoch
=
ntohu64
(
hdr
->
currentEpoch
);
senderConfigEpoch
=
ntohu64
(
hdr
->
configEpoch
);
if
(
senderCurrentEpoch
>
server
.
cluster
->
currentEpoch
)
server
.
cluster
->
currentEpoch
=
senderCurrentEpoch
;
}
/* Process packets by type. */
if
(
type
==
CLUSTERMSG_TYPE_PING
||
type
==
CLUSTERMSG_TYPE_MEET
)
{
if
(
type
==
CLUSTERMSG_TYPE_PING
||
type
==
CLUSTERMSG_TYPE_MEET
)
{
int
update_config
=
0
;
int
update_config
=
0
;
redisLog
(
REDIS_DEBUG
,
"Ping packet received: %p"
,
(
void
*
)
link
->
node
);
redisLog
(
REDIS_DEBUG
,
"Ping packet received: %p"
,
(
void
*
)
link
->
node
);
...
...
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