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
d2040ab9
Commit
d2040ab9
authored
Feb 26, 2014
by
Matt Stancliff
Committed by
antirez
Mar 06, 2014
Browse files
Remove some redundant code
Function nodeIp2String in cluster.c is exactly anetPeerToString with a pre-extracted fd.
parent
59cf0b19
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
d2040ab9
...
@@ -1021,22 +1021,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
...
@@ -1021,22 +1021,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
/* IP -> string conversion. 'buf' is supposed to at least be 46 bytes. */
/* IP -> string conversion. 'buf' is supposed to at least be 46 bytes. */
void
nodeIp2String
(
char
*
buf
,
clusterLink
*
link
)
{
void
nodeIp2String
(
char
*
buf
,
clusterLink
*
link
)
{
struct
sockaddr_storage
sa
;
anetPeerToString
(
link
->
fd
,
buf
,
REDIS_CLUSTER_IPLEN
,
NULL
);
socklen_t
salen
=
sizeof
(
sa
);
if
(
getpeername
(
link
->
fd
,
(
struct
sockaddr
*
)
&
sa
,
&
salen
)
==
-
1
)
redisPanic
(
"getpeername() failed."
);
if
(
sa
.
ss_family
==
AF_INET
)
{
struct
sockaddr_in
*
s
=
(
struct
sockaddr_in
*
)
&
sa
;
inet_ntop
(
AF_INET
,(
void
*
)
&
(
s
->
sin_addr
),
buf
,
REDIS_CLUSTER_IPLEN
);
}
else
{
struct
sockaddr_in6
*
s
=
(
struct
sockaddr_in6
*
)
&
sa
;
inet_ntop
(
AF_INET6
,(
void
*
)
&
(
s
->
sin6_addr
),
buf
,
REDIS_CLUSTER_IPLEN
);
}
}
}
/* Update the node address to the IP address that can be extracted
/* Update the node address to the IP address that can be extracted
* from link->fd, and at the specified port.
* from link->fd, and at the specified port.
* Also disconnect the node link so that we'll connect again to the new
* Also disconnect the node link so that we'll connect again to the new
...
...
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