Skip to content

Commit

Permalink
reduce some code delta
Browse files Browse the repository at this point in the history
Signed-off-by: Roshan Khatri <[email protected]>
  • Loading branch information
roshkhatri committed Jul 16, 2024
1 parent 3d2c38e commit ff31e96
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3039,7 +3039,7 @@ int clusterProcessPacket(clusterLink *link) {
}
return 1;
}
clusterNode *sender;

clusterMsg *hdr = (clusterMsg *)link->rcvbuf;
uint16_t type = ntohs(hdr->type);
mstime_t now = mstime();
Expand All @@ -3053,20 +3053,14 @@ int clusterProcessPacket(clusterLink *link) {
type);
return 0;
}
sender = link->node;
clusterNode *sender = link->node;
sender->data_received = now;
return pubsubProcessLightPacket(link, type);
}

sender = getNodeFromLinkAndMsg(link, hdr);
/* Update the last time we saw any data from this node. We
* use this in order to avoid detecting a timeout from a node that
* is just sending a lot of data in the cluster bus, for instance
* because of Pub/Sub. */
if (sender) sender->data_received = now;

uint16_t flags = ntohs(hdr->flags);
uint64_t sender_claimed_current_epoch = 0, sender_claimed_config_epoch = 0;
clusterNode *sender = getNodeFromLinkAndMsg(link, hdr);
int sender_claims_to_be_primary = !memcmp(hdr->replicaof, CLUSTER_NODE_NULL_NAME, CLUSTER_NAMELEN);
int sender_last_reported_as_replica = sender && nodeIsReplica(sender);
int sender_last_reported_as_primary = sender && nodeIsPrimary(sender);
Expand All @@ -3075,15 +3069,17 @@ int clusterProcessPacket(clusterLink *link) {
sender->flags |= CLUSTER_NODE_EXTENSIONS_SUPPORTED;
}

if (sender && (hdr->mflags[0] & CLUSTERMSG_FLAG0_EXT_DATA)) {
sender->flags |= CLUSTER_NODE_EXTENSIONS_SUPPORTED;
}

/* Checks if the node supports light message hdr */
if (sender && (flags & CLUSTER_NODE_LIGHT_HDR_SUPPORTED)) {
sender->flags |= CLUSTER_NODE_LIGHT_HDR_SUPPORTED;
}

/* Update the last time we saw any data from this node. We
* use this in order to avoid detecting a timeout from a node that
* is just sending a lot of data in the cluster bus, for instance
* because of Pub/Sub. */
if (sender) sender->data_received = now;

if (sender && !nodeInHandshake(sender)) {
/* Update our currentEpoch if we see a newer epoch in the cluster. */
sender_claimed_current_epoch = ntohu64(hdr->currentEpoch);
Expand Down

0 comments on commit ff31e96

Please sign in to comment.