From a97df1a6e104e9e578c246eb3cf4b263370d8b05 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 30 Mar 2018 13:16:07 +0200 Subject: [PATCH] Modules Cluster API: make node IDs pointers constant. --- src/cluster.c | 8 ++++---- src/module.c | 4 ++-- src/redismodule.h | 2 +- src/server.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 0faa987e5..0635d7c07 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -56,7 +56,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request); void clusterUpdateState(void); int clusterNodeGetSlotBit(clusterNode *n, int slot); sds clusterGenNodesDescription(int filter); -clusterNode *clusterLookupNode(char *name); +clusterNode *clusterLookupNode(const char *name); int clusterNodeAddSlave(clusterNode *master, clusterNode *slave); int clusterAddSlot(clusterNode *n, int slot); int clusterDelSlot(int slot); @@ -75,7 +75,7 @@ void clusterDelNode(clusterNode *delnode); sds representClusterNodeFlags(sds ci, uint16_t flags); uint64_t clusterGetMaxEpoch(void); int clusterBumpConfigEpochWithoutConsensus(void); -void moduleCallClusterReceivers(char *sender_id, uint64_t module_id, uint8_t type, const unsigned char *payload, uint32_t len); +void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8_t type, const unsigned char *payload, uint32_t len); /* ----------------------------------------------------------------------------- * Initialization @@ -932,7 +932,7 @@ void clusterDelNode(clusterNode *delnode) { } /* Node lookup by name */ -clusterNode *clusterLookupNode(char *name) { +clusterNode *clusterLookupNode(const char *name) { sds s = sdsnewlen(name, CLUSTER_NAMELEN); dictEntry *de; @@ -2621,7 +2621,7 @@ void clusterSendModule(clusterLink *link, uint64_t module_id, uint8_t type, * * The function returns C_OK if the target is valid, otherwise C_ERR is * returned. */ -int clusterSendModuleMessageToTarget(char *target, uint64_t module_id, uint8_t type, unsigned char *payload, uint32_t len) { +int clusterSendModuleMessageToTarget(const char *target, uint64_t module_id, uint8_t type, unsigned char *payload, uint32_t len) { clusterNode *node = NULL; if (target != NULL) { diff --git a/src/module.c b/src/module.c index 3e6c71dfe..9098281d8 100644 --- a/src/module.c +++ b/src/module.c @@ -3813,7 +3813,7 @@ void moduleUnsubscribeNotifications(RedisModule *module) { * -------------------------------------------------------------------------- */ /* The Cluster message callback function pointer type. */ -typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); +typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); /* This structure identifies a registered caller: it must match a given module * ID, for a given message type. The callback function is just the function @@ -3830,7 +3830,7 @@ typedef struct moduleClusterReceiver { static moduleClusterReceiver *clusterReceivers[UINT8_MAX]; /* Dispatch the message to the right module receiver. */ -void moduleCallClusterReceivers(char *sender_id, uint64_t module_id, uint8_t type, const unsigned char *payload, uint32_t len) { +void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8_t type, const unsigned char *payload, uint32_t len) { moduleClusterReceiver *r = clusterReceivers[type]; while(r) { if (r->module_id == module_id) { diff --git a/src/redismodule.h b/src/redismodule.h index 5d400681b..590900ce7 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -133,7 +133,7 @@ typedef void (*RedisModuleTypeRewriteFunc)(RedisModuleIO *aof, RedisModuleString typedef size_t (*RedisModuleTypeMemUsageFunc)(const void *value); typedef void (*RedisModuleTypeDigestFunc)(RedisModuleDigest *digest, void *value); typedef void (*RedisModuleTypeFreeFunc)(void *value); -typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); +typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); #define REDISMODULE_TYPE_METHOD_VERSION 1 typedef struct RedisModuleTypeMethods { diff --git a/src/server.h b/src/server.h index cca56bc35..682129d0b 100644 --- a/src/server.h +++ b/src/server.h @@ -1808,7 +1808,7 @@ void clusterCron(void); void clusterPropagatePublish(robj *channel, robj *message); void migrateCloseTimedoutSockets(void); void clusterBeforeSleep(void); -int clusterSendModuleMessageToTarget(char *target, uint64_t module_id, uint8_t type, unsigned char *payload, uint32_t len); +int clusterSendModuleMessageToTarget(const char *target, uint64_t module_id, uint8_t type, unsigned char *payload, uint32_t len); /* Sentinel */ void initSentinelConfig(void);