From 4ef4e81c6267e4e778f31fed530e378a62b86888 Mon Sep 17 00:00:00 2001 From: Harkrishn Patro Date: Fri, 17 Jan 2025 02:26:14 +0000 Subject: [PATCH] Add node flag for light message hdr support for module type Signed-off-by: Harkrishn Patro --- src/cluster_legacy.c | 18 ++++++++++++------ src/cluster_legacy.h | 6 ++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 6f48581218..087c6dede4 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -1006,7 +1006,7 @@ void clusterUpdateMyselfFlags(void) { int nofailover = server.cluster_replica_no_failover ? CLUSTER_NODE_NOFAILOVER : 0; myself->flags &= ~CLUSTER_NODE_NOFAILOVER; myself->flags |= nofailover; - myself->flags |= CLUSTER_NODE_LIGHT_HDR_SUPPORTED; + myself->flags |= CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED | CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED; if (myself->flags != oldflags) { clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG | CLUSTER_TODO_UPDATE_STATE); } @@ -3221,10 +3221,16 @@ int clusterProcessPacket(clusterLink *link) { /* Checks if the node supports light message hdr */ if (sender) { - if (flags & CLUSTER_NODE_LIGHT_HDR_SUPPORTED) { - sender->flags |= CLUSTER_NODE_LIGHT_HDR_SUPPORTED; + if (flags & CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED) { + sender->flags |= CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED; } else { - sender->flags &= ~CLUSTER_NODE_LIGHT_HDR_SUPPORTED; + sender->flags &= ~CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED; + } + + if (flags & CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED) { + sender->flags |= CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED; + } else { + sender->flags &= ~CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED; } } @@ -4361,7 +4367,7 @@ void clusterSendModule(clusterLink *link, uint64_t module_id, uint8_t type, cons clusterNode *node; while ((node = clusterNodeIterNext(&iter)) != NULL) { if (node->flags & (CLUSTER_NODE_MYSELF | CLUSTER_NODE_HANDSHAKE)) continue; - if (nodeSupportsLightMsgHdr(node)) { + if (nodeSupportsLightMsgHdrForModule(node)) { if (msgblock_light == NULL) { uint32_t msglen_light = sizeof(clusterMsgLight) - sizeof(union clusterMsgData); msglen_light += sizeof(clusterMsgModule) - 3 + len; @@ -4442,7 +4448,7 @@ void clusterPropagatePublish(robj *channel, robj *message, int sharded) { clusterNode *node; while ((node = clusterNodeIterNext(&iter)) != NULL) { if (node->flags & (CLUSTER_NODE_MYSELF | CLUSTER_NODE_HANDSHAKE)) continue; - if (nodeSupportsLightMsgHdr(node)) { + if (nodeSupportsLightMsgHdrForPubSub(node)) { clusterSendMessage(node->link, msgblock_light); } else { if (msgblock == NULL) { diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index 226842c5dc..b808ca33da 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -53,7 +53,8 @@ typedef struct clusterLink { #define CLUSTER_NODE_MIGRATE_TO (1 << 8) /* Primary eligible for replica migration. */ #define CLUSTER_NODE_NOFAILOVER (1 << 9) /* Replica will not try to failover. */ #define CLUSTER_NODE_EXTENSIONS_SUPPORTED (1 << 10) /* This node supports extensions. */ -#define CLUSTER_NODE_LIGHT_HDR_SUPPORTED (1 << 11) /* This node supports light pubsub message header. */ +#define CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED (1 << 11) /* This node supports light message header for publish type. */ +#define CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED (1 << 12) /* This node supports light message header for module type. */ #define CLUSTER_NODE_NULL_NAME \ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" \ "\000\000\000\000\000\000\000\000\000\000\000\000" @@ -67,7 +68,8 @@ typedef struct clusterLink { #define nodeFailed(n) ((n)->flags & CLUSTER_NODE_FAIL) #define nodeCantFailover(n) ((n)->flags & CLUSTER_NODE_NOFAILOVER) #define nodeSupportsExtensions(n) ((n)->flags & CLUSTER_NODE_EXTENSIONS_SUPPORTED) -#define nodeSupportsLightMsgHdr(n) ((n)->flags & CLUSTER_NODE_LIGHT_HDR_SUPPORTED) +#define nodeSupportsLightMsgHdrForPubSub(n) ((n)->flags & CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED) +#define nodeSupportsLightMsgHdrForModule(n) ((n)->flags & CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED) #define nodeInNormalState(n) (!((n)->flags & (CLUSTER_NODE_HANDSHAKE | CLUSTER_NODE_MEET | CLUSTER_NODE_PFAIL | CLUSTER_NODE_FAIL))) /* This structure represent elements of node->fail_reports. */