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
d289c628
Commit
d289c628
authored
Nov 08, 2013
by
antirez
Browse files
Cluster: replace hardcoded 4096 for bus msg len with sizeof().
parent
94a07d59
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
d289c628
...
@@ -1327,7 +1327,7 @@ void clusterWriteHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
...
@@ -1327,7 +1327,7 @@ void clusterWriteHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
* full length of the packet. When a whole packet is in memory this function
* full length of the packet. When a whole packet is in memory this function
* will call the function to process the packet. And so forth. */
* will call the function to process the packet. And so forth. */
void
clusterReadHandler
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
void
clusterReadHandler
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
char
buf
[
4096
];
char
buf
[
sizeof
(
clusterMsg
)
];
ssize_t
nread
;
ssize_t
nread
;
clusterMsg
*
hdr
;
clusterMsg
*
hdr
;
clusterLink
*
link
=
(
clusterLink
*
)
privdata
;
clusterLink
*
link
=
(
clusterLink
*
)
privdata
;
...
@@ -1466,7 +1466,7 @@ void clusterBuildMessageHdr(clusterMsg *hdr, int type) {
...
@@ -1466,7 +1466,7 @@ void clusterBuildMessageHdr(clusterMsg *hdr, int type) {
/* Send a PING or PONG packet to the specified node, making sure to add enough
/* Send a PING or PONG packet to the specified node, making sure to add enough
* gossip informations. */
* gossip informations. */
void
clusterSendPing
(
clusterLink
*
link
,
int
type
)
{
void
clusterSendPing
(
clusterLink
*
link
,
int
type
)
{
unsigned
char
buf
[
4096
];
unsigned
char
buf
[
sizeof
(
clusterMsg
)
];
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
int
gossipcount
=
0
,
totlen
;
int
gossipcount
=
0
,
totlen
;
/* freshnodes is the number of nodes we can still use to populate the
/* freshnodes is the number of nodes we can still use to populate the
...
@@ -1553,7 +1553,7 @@ void clusterBroadcastPong(void) {
...
@@ -1553,7 +1553,7 @@ void clusterBroadcastPong(void) {
*
*
* If link is NULL, then the message is broadcasted to the whole cluster. */
* If link is NULL, then the message is broadcasted to the whole cluster. */
void
clusterSendPublish
(
clusterLink
*
link
,
robj
*
channel
,
robj
*
message
)
{
void
clusterSendPublish
(
clusterLink
*
link
,
robj
*
channel
,
robj
*
message
)
{
unsigned
char
buf
[
4096
],
*
payload
;
unsigned
char
buf
[
sizeof
(
clusterMsg
)
],
*
payload
;
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
uint32_t
totlen
;
uint32_t
totlen
;
uint32_t
channel_len
,
message_len
;
uint32_t
channel_len
,
message_len
;
...
@@ -1599,7 +1599,7 @@ void clusterSendPublish(clusterLink *link, robj *channel, robj *message) {
...
@@ -1599,7 +1599,7 @@ void clusterSendPublish(clusterLink *link, robj *channel, robj *message) {
* we switch the node state to REDIS_NODE_FAIL and ask all the other
* we switch the node state to REDIS_NODE_FAIL and ask all the other
* nodes to do the same ASAP. */
* nodes to do the same ASAP. */
void
clusterSendFail
(
char
*
nodename
)
{
void
clusterSendFail
(
char
*
nodename
)
{
unsigned
char
buf
[
4096
];
unsigned
char
buf
[
sizeof
(
clusterMsg
)
];
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterBuildMessageHdr
(
hdr
,
CLUSTERMSG_TYPE_FAIL
);
clusterBuildMessageHdr
(
hdr
,
CLUSTERMSG_TYPE_FAIL
);
...
@@ -1611,7 +1611,7 @@ void clusterSendFail(char *nodename) {
...
@@ -1611,7 +1611,7 @@ void clusterSendFail(char *nodename) {
* slots configuration. The node name, slots bitmap, and configEpoch info
* slots configuration. The node name, slots bitmap, and configEpoch info
* are included. */
* are included. */
void
clusterSendUpdate
(
clusterLink
*
link
,
clusterNode
*
node
)
{
void
clusterSendUpdate
(
clusterLink
*
link
,
clusterNode
*
node
)
{
unsigned
char
buf
[
4096
];
unsigned
char
buf
[
sizeof
(
clusterMsg
)
];
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterBuildMessageHdr
(
hdr
,
CLUSTERMSG_TYPE_UPDATE
);
clusterBuildMessageHdr
(
hdr
,
CLUSTERMSG_TYPE_UPDATE
);
...
@@ -1643,7 +1643,7 @@ void clusterPropagatePublish(robj *channel, robj *message) {
...
@@ -1643,7 +1643,7 @@ void clusterPropagatePublish(robj *channel, robj *message) {
* Note that we send the failover request to everybody, master and slave nodes,
* Note that we send the failover request to everybody, master and slave nodes,
* but only the masters are supposed to reply to our query. */
* but only the masters are supposed to reply to our query. */
void
clusterRequestFailoverAuth
(
void
)
{
void
clusterRequestFailoverAuth
(
void
)
{
unsigned
char
buf
[
4096
];
unsigned
char
buf
[
sizeof
(
clusterMsg
)
];
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
uint32_t
totlen
;
uint32_t
totlen
;
...
@@ -1655,7 +1655,7 @@ void clusterRequestFailoverAuth(void) {
...
@@ -1655,7 +1655,7 @@ void clusterRequestFailoverAuth(void) {
/* Send a FAILOVER_AUTH_ACK message to the specified node. */
/* Send a FAILOVER_AUTH_ACK message to the specified node. */
void
clusterSendFailoverAuth
(
clusterNode
*
node
)
{
void
clusterSendFailoverAuth
(
clusterNode
*
node
)
{
unsigned
char
buf
[
4096
];
unsigned
char
buf
[
sizeof
(
clusterMsg
)
];
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
clusterMsg
*
hdr
=
(
clusterMsg
*
)
buf
;
uint32_t
totlen
;
uint32_t
totlen
;
...
...
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