mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-21 23:58:51 -05:00
all: another pass on Redis references in src/*
This is *nearly* all of them in src/*. Signed-off-by: Drew DeVault <sir@cmpwn.com>
This commit is contained in:
parent
de1c901886
commit
b27a9862d1
57
src/aof.c
57
src/aof.c
@ -587,7 +587,7 @@ int persistAofManifest(aofManifest *am) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Called in `loadAppendOnlyFiles` when we upgrade from a old version redis.
|
||||
/* Called in `loadAppendOnlyFiles` when we upgrade from a old version of Redict.
|
||||
*
|
||||
* 1) Create AOF directory use 'server.aof_dirname' as the name.
|
||||
* 2) Use 'server.aof_filename' to construct a BASE type aofInfo and add it to
|
||||
@ -595,7 +595,7 @@ int persistAofManifest(aofManifest *am) {
|
||||
* 3) Move the old AOF file (server.aof_filename) to AOF directory.
|
||||
*
|
||||
* If any of the above steps fails or crash occurs, this will not cause any
|
||||
* problems, and redis will retry the upgrade process when it restarts.
|
||||
* problems, and Redict will retry the upgrade process when it restarts.
|
||||
*/
|
||||
void aofUpgradePrepare(aofManifest *am) {
|
||||
serverAssert(!aofFileExist(server.aof_filename));
|
||||
@ -682,13 +682,13 @@ void aofDelTempIncrAofFile(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Called after `loadDataFromDisk` when redis start. If `server.aof_state` is
|
||||
/* Called after `loadDataFromDisk` when Redict starts. If `server.aof_state` is
|
||||
* 'AOF_ON', It will do three things:
|
||||
* 1. Force create a BASE file when redis starts with an empty dataset
|
||||
* 1. Force create a BASE file when Redict starts with an empty dataset
|
||||
* 2. Open the last opened INCR type AOF for writing, If not, create a new one
|
||||
* 3. Synchronously update the manifest file to the disk
|
||||
*
|
||||
* If any of the above steps fails, the redis process will exit.
|
||||
* If any of the above steps fails, the Redict process will exit.
|
||||
*/
|
||||
void aofOpenIfNeededOnServerStart(void) {
|
||||
if (server.aof_state != AOF_ON) {
|
||||
@ -762,9 +762,9 @@ int aofFileExist(char *filename) {
|
||||
* The above two steps of modification are atomic, that is, if
|
||||
* any step fails, the entire operation will rollback and returns
|
||||
* C_ERR, and if all succeeds, it returns C_OK.
|
||||
*
|
||||
* If `server.aof_state` is 'AOF_WAIT_REWRITE', It will open a temporary INCR AOF
|
||||
* file to accumulate data during AOF_WAIT_REWRITE, and it will eventually be
|
||||
*
|
||||
* If `server.aof_state` is 'AOF_WAIT_REWRITE', It will open a temporary INCR AOF
|
||||
* file to accumulate data during AOF_WAIT_REWRITE, and it will eventually be
|
||||
* renamed in the `backgroundRewriteDoneHandler` and written to the manifest file.
|
||||
* */
|
||||
int openNewIncrAofForAppend(void) {
|
||||
@ -834,7 +834,7 @@ cleanup:
|
||||
|
||||
/* Whether to limit the execution of Background AOF rewrite.
|
||||
*
|
||||
* At present, if AOFRW fails, redis will automatically retry. If it continues
|
||||
* At present, if AOFRW fails, Redict will automatically retry. If it continues
|
||||
* to fail, we may get a lot of very small INCR files. so we need an AOFRW
|
||||
* limiting measure.
|
||||
*
|
||||
@ -1420,7 +1420,7 @@ int loadSingleAppendOnlyFile(char *filename) {
|
||||
server.current_client = server.executing_client = fakeClient;
|
||||
|
||||
/* Check if the AOF file is in RDB format (it may be RDB encoded base AOF
|
||||
* or old style RDB-preamble AOF). In that case we need to load the RDB file
|
||||
* or old style RDB-preamble AOF). In that case we need to load the RDB file
|
||||
* and later continue loading the AOF tail if it is an old style RDB-preamble AOF. */
|
||||
char sig[5]; /* "REDIS" */
|
||||
if (fread(sig,1,5,fp) != 5 || memcmp(sig,"REDIS",5) != 0) {
|
||||
@ -1432,8 +1432,8 @@ int loadSingleAppendOnlyFile(char *filename) {
|
||||
int old_style = !strcmp(filename, server.aof_filename);
|
||||
if (old_style)
|
||||
serverLog(LL_NOTICE, "Reading RDB preamble from AOF file...");
|
||||
else
|
||||
serverLog(LL_NOTICE, "Reading RDB base file on AOF loading...");
|
||||
else
|
||||
serverLog(LL_NOTICE, "Reading RDB base file on AOF loading...");
|
||||
|
||||
if (fseek(fp,0,SEEK_SET) == -1) goto readerr;
|
||||
rioInitWithFile(&rdb,fp);
|
||||
@ -1641,8 +1641,9 @@ int loadAppendOnlyFiles(aofManifest *am) {
|
||||
sds aof_name;
|
||||
int total_num, aof_num = 0, last_file;
|
||||
|
||||
/* If the 'server.aof_filename' file exists in dir, we may be starting
|
||||
* from an old redis version. We will use enter upgrade mode in three situations.
|
||||
/* If the 'server.aof_filename' file exists in dir, we may be starting from
|
||||
* an old Redict version. We will use enter upgrade mode in three
|
||||
* situations.
|
||||
*
|
||||
* 1. If the 'server.aof_dirname' directory not exist
|
||||
* 2. If the 'server.aof_dirname' directory exists but the manifest file is missing
|
||||
@ -1789,7 +1790,7 @@ int rewriteListObject(rio *r, robj *key, robj *o) {
|
||||
AOF_REWRITE_ITEMS_PER_CMD : items;
|
||||
if (!rioWriteBulkCount(r,'*',2+cmd_items) ||
|
||||
!rioWriteBulkString(r,"RPUSH",5) ||
|
||||
!rioWriteBulkObject(r,key))
|
||||
!rioWriteBulkObject(r,key))
|
||||
{
|
||||
listTypeReleaseIterator(li);
|
||||
return 0;
|
||||
@ -1879,7 +1880,7 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
|
||||
|
||||
if (!rioWriteBulkCount(r,'*',2+cmd_items*2) ||
|
||||
!rioWriteBulkString(r,"ZADD",4) ||
|
||||
!rioWriteBulkObject(r,key))
|
||||
!rioWriteBulkObject(r,key))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -1909,7 +1910,7 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
|
||||
|
||||
if (!rioWriteBulkCount(r,'*',2+cmd_items*2) ||
|
||||
!rioWriteBulkString(r,"ZADD",4) ||
|
||||
!rioWriteBulkObject(r,key))
|
||||
!rioWriteBulkObject(r,key))
|
||||
{
|
||||
dictReleaseIterator(di);
|
||||
return 0;
|
||||
@ -1971,7 +1972,7 @@ int rewriteHashObject(rio *r, robj *key, robj *o) {
|
||||
|
||||
if (!rioWriteBulkCount(r,'*',2+cmd_items*2) ||
|
||||
!rioWriteBulkString(r,"HMSET",5) ||
|
||||
!rioWriteBulkObject(r,key))
|
||||
!rioWriteBulkObject(r,key))
|
||||
{
|
||||
hashTypeReleaseIterator(hi);
|
||||
return 0;
|
||||
@ -1982,7 +1983,7 @@ int rewriteHashObject(rio *r, robj *key, robj *o) {
|
||||
!rioWriteHashIteratorCursor(r, hi, OBJ_HASH_VALUE))
|
||||
{
|
||||
hashTypeReleaseIterator(hi);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0;
|
||||
items--;
|
||||
@ -2059,10 +2060,10 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
|
||||
* the ID, the second is an array of field-value pairs. */
|
||||
|
||||
/* Emit the XADD <key> <id> ...fields... command. */
|
||||
if (!rioWriteBulkCount(r,'*',3+numfields*2) ||
|
||||
if (!rioWriteBulkCount(r,'*',3+numfields*2) ||
|
||||
!rioWriteBulkString(r,"XADD",4) ||
|
||||
!rioWriteBulkObject(r,key) ||
|
||||
!rioWriteBulkStreamID(r,&id))
|
||||
!rioWriteBulkStreamID(r,&id))
|
||||
{
|
||||
streamIteratorStop(&si);
|
||||
return 0;
|
||||
@ -2072,10 +2073,10 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
|
||||
int64_t field_len, value_len;
|
||||
streamIteratorGetField(&si,&field,&value,&field_len,&value_len);
|
||||
if (!rioWriteBulkString(r,(char*)field,field_len) ||
|
||||
!rioWriteBulkString(r,(char*)value,value_len))
|
||||
!rioWriteBulkString(r,(char*)value,value_len))
|
||||
{
|
||||
streamIteratorStop(&si);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2083,7 +2084,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
|
||||
/* Use the XADD MAXLEN 0 trick to generate an empty stream if
|
||||
* the key we are serializing is an empty string, which is possible
|
||||
* for the Stream type. */
|
||||
id.ms = 0; id.seq = 1;
|
||||
id.ms = 0; id.seq = 1;
|
||||
if (!rioWriteBulkCount(r,'*',7) ||
|
||||
!rioWriteBulkString(r,"XADD",4) ||
|
||||
!rioWriteBulkObject(r,key) ||
|
||||
@ -2094,7 +2095,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
|
||||
!rioWriteBulkString(r,"y",1))
|
||||
{
|
||||
streamIteratorStop(&si);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2107,10 +2108,10 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
|
||||
!rioWriteBulkString(r,"ENTRIESADDED",12) ||
|
||||
!rioWriteBulkLongLong(r,s->entries_added) ||
|
||||
!rioWriteBulkString(r,"MAXDELETEDID",12) ||
|
||||
!rioWriteBulkStreamID(r,&s->max_deleted_entry_id))
|
||||
!rioWriteBulkStreamID(r,&s->max_deleted_entry_id))
|
||||
{
|
||||
streamIteratorStop(&si);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -2483,7 +2484,7 @@ void bgrewriteaofCommand(client *c) {
|
||||
addReplyError(c,"Background append only file rewriting already in progress");
|
||||
} else if (hasActiveChildProcess() || server.in_exec) {
|
||||
server.aof_rewrite_scheduled = 1;
|
||||
/* When manually triggering AOFRW we reset the count
|
||||
/* When manually triggering AOFRW we reset the count
|
||||
* so that it can be executed immediately. */
|
||||
server.stat_aofrw_consecutive_failures = 0;
|
||||
addReplyStatus(c,"Background append only file rewriting scheduled");
|
||||
|
@ -14,13 +14,13 @@
|
||||
/* Define redictAtomic for atomic variable. */
|
||||
#define redictAtomic
|
||||
|
||||
/* To test Redis with Helgrind (a Valgrind tool) it is useful to define
|
||||
/* To test Redict with Helgrind (a Valgrind tool) it is useful to define
|
||||
* the following macro, so that __sync macros are used: those can be detected
|
||||
* by Helgrind (even if they are less efficient) so that no false positive
|
||||
* is reported. */
|
||||
// #define __ATOMIC_VAR_FORCE_SYNC_MACROS
|
||||
|
||||
/* There will be many false positives if we test Redis with Helgrind, since
|
||||
/* There will be many false positives if we test Redict with Helgrind, since
|
||||
* Helgrind can't understand we have imposed ordering on the program, so
|
||||
* we use macros in helgrind.h to tell Helgrind inter-thread happens-before
|
||||
* relationship explicitly for avoiding false positives.
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define __CLUSTER_H
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Redis cluster exported API.
|
||||
* Redict cluster exported API.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define CLUSTER_SLOT_MASK_BITS 14 /* Number of bits used for slot id. */
|
||||
@ -31,9 +31,9 @@
|
||||
typedef struct _clusterNode clusterNode;
|
||||
struct clusterState;
|
||||
|
||||
/* Flags that a module can set in order to prevent certain Redis Cluster
|
||||
/* Flags that a module can set in order to prevent certain Redict Cluster
|
||||
* features to be enabled. Useful when implementing a different distributed
|
||||
* system on top of Redis Cluster message bus, using modules. */
|
||||
* system on top of Redict Cluster message bus, using modules. */
|
||||
#define CLUSTER_MODULE_FLAG_NONE 0
|
||||
#define CLUSTER_MODULE_FLAG_NO_FAILOVER (1<<1)
|
||||
#define CLUSTER_MODULE_FLAG_NO_REDIRECTION (1<<2)
|
||||
|
@ -72,7 +72,7 @@ typedef struct clusterNodeFailReport {
|
||||
mstime_t time; /* Time of the last report from this node. */
|
||||
} clusterNodeFailReport;
|
||||
|
||||
/* Redis cluster messages header */
|
||||
/* Redict cluster messages header */
|
||||
|
||||
/* Message types.
|
||||
*
|
||||
@ -210,7 +210,7 @@ union clusterMsgData {
|
||||
#define CLUSTER_PROTO_VER 1 /* Cluster bus protocol version. */
|
||||
|
||||
typedef struct {
|
||||
char sig[4]; /* Signature "RCmb" (Redis Cluster message bus). */
|
||||
char sig[4]; /* Signature "RCmb" (Redict Cluster message bus). */
|
||||
uint32_t totlen; /* Total length of this message */
|
||||
uint16_t ver; /* Protocol version, currently set to 1. */
|
||||
uint16_t port; /* Primary port number (TCP or TLS). */
|
||||
@ -237,7 +237,7 @@ typedef struct {
|
||||
union clusterMsgData data;
|
||||
} clusterMsg;
|
||||
|
||||
/* clusterMsg defines the gossip wire protocol exchanged among Redis cluster
|
||||
/* clusterMsg defines the gossip wire protocol exchanged among Redict cluster
|
||||
* members, which can be running different versions of redict-server bits,
|
||||
* especially during cluster rolling upgrades.
|
||||
*
|
||||
|
@ -203,7 +203,7 @@ void setproctitle(const char *fmt, ...);
|
||||
|
||||
/* Sometimes after including an OS-specific header that defines the
|
||||
* endianness we end with __BYTE_ORDER but not with BYTE_ORDER that is what
|
||||
* the Redis code uses. In this case let's define everything without the
|
||||
* the Redict code uses. In this case let's define everything without the
|
||||
* underscores. */
|
||||
#ifndef BYTE_ORDER
|
||||
#ifdef __BYTE_ORDER
|
||||
|
@ -184,7 +184,7 @@ static inline int connWritev(connection *conn, const struct iovec *iov, int iovc
|
||||
}
|
||||
|
||||
/* Read from the connection, behaves the same as read(2).
|
||||
*
|
||||
*
|
||||
* Like read(2), a short read is possible. A return value of 0 will indicate the
|
||||
* connection was closed, and -1 will indicate an error.
|
||||
*
|
||||
@ -267,7 +267,7 @@ static inline int connAddr(connection *conn, char *ip, size_t ip_len, int *port,
|
||||
|
||||
/* Format an IP,port pair into something easy to parse. If IP is IPv6
|
||||
* (matches for ":"), the ip is surrounded by []. IP and port are just
|
||||
* separated by colons. This the standard to display addresses within Redis. */
|
||||
* separated by colons. This the standard to display addresses within Redict. */
|
||||
static inline int formatAddr(char *buf, size_t buf_len, char *ip, int port) {
|
||||
return snprintf(buf, buf_len, strchr(ip,':') ?
|
||||
"[%s]:%d" : "%s:%d", ip, port);
|
||||
@ -355,10 +355,10 @@ static inline sds connGetPeerCert(connection *conn) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize the redis connection framework */
|
||||
/* Initialize the redict connection framework */
|
||||
int connTypeInitialize(void);
|
||||
|
||||
/* Register a connection type into redis connection framework */
|
||||
/* Register a connection type into redict connection framework */
|
||||
int connTypeRegister(ConnectionType *ct);
|
||||
|
||||
/* Lookup a connection type by type name */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,8 +42,8 @@
|
||||
* will error on stdlib definitions in files as well*/
|
||||
#if (__GNUC__ && __GNUC__ >= 4) && !defined __APPLE__
|
||||
int sprintf(char *str, const char *format, ...) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of snprintf instead")));
|
||||
char *strcpy(char *restrict dest, const char *src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of redis_strlcpy instead")));
|
||||
char *strcat(char *restrict dest, const char *restrict src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of redis_strlcat instead")));
|
||||
char *strcpy(char *restrict dest, const char *src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of redict_strlcpy instead")));
|
||||
char *strcat(char *restrict dest, const char *restrict src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of redict_strlcat instead")));
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define __FUNCTIONS_H_
|
||||
|
||||
/*
|
||||
* functions.c unit provides the Redis Functions API:
|
||||
* functions.c unit provides the Redict Functions API:
|
||||
* * FUNCTION LOAD
|
||||
* * FUNCTION LIST
|
||||
* * FUNCTION CALL (FCALL and FCALL_RO)
|
||||
@ -46,7 +46,7 @@ typedef struct engine {
|
||||
int (*create)(void *engine_ctx, functionLibInfo *li, sds code, size_t timeout, sds *err);
|
||||
|
||||
/* Invoking a function, r_ctx is an opaque object (from engine POV).
|
||||
* The r_ctx should be used by the engine to interaction with Redis,
|
||||
* The r_ctx should be used by the engine to interaction with Redict,
|
||||
* such interaction could be running commands, set resp, or set
|
||||
* replication mode
|
||||
*/
|
||||
|
270
src/module.c
270
src/module.c
@ -113,7 +113,7 @@ struct RedictModuleCtx {
|
||||
gets called for clients blocked
|
||||
on keys. */
|
||||
|
||||
/* Used if there is the REDICTMODULE_CTX_KEYS_POS_REQUEST or
|
||||
/* Used if there is the REDICTMODULE_CTX_KEYS_POS_REQUEST or
|
||||
* REDICTMODULE_CTX_CHANNEL_POS_REQUEST flag set. */
|
||||
getKeysResult *keys_result;
|
||||
|
||||
@ -192,7 +192,7 @@ typedef void (*RedictModuleDisconnectFunc) (RedictModuleCtx *ctx, struct RedictM
|
||||
struct RedictModuleCommand {
|
||||
struct RedictModule *module;
|
||||
RedictModuleCmdFunc func;
|
||||
struct redictCommand *rediscmd;
|
||||
struct redictCommand *redictcmd;
|
||||
};
|
||||
typedef struct RedictModuleCommand RedictModuleCommand;
|
||||
|
||||
@ -372,27 +372,27 @@ typedef struct RedictModuleEventListener {
|
||||
|
||||
list *RedictModule_EventListeners; /* Global list of all the active events. */
|
||||
|
||||
/* Data structures related to the redis module users */
|
||||
/* Data structures related to the redict module users */
|
||||
|
||||
/* This is the object returned by RM_CreateModuleUser(). The module API is
|
||||
* able to create users, set ACLs to such users, and later authenticate
|
||||
* clients using such newly created users. */
|
||||
typedef struct RedictModuleUser {
|
||||
user *user; /* Reference to the real redis user */
|
||||
user *user; /* Reference to the real redict user */
|
||||
int free_user; /* Indicates that user should also be freed when this object is freed */
|
||||
} RedictModuleUser;
|
||||
|
||||
/* This is a structure used to export some meta-information such as dbid to the module. */
|
||||
typedef struct RedictModuleKeyOptCtx {
|
||||
struct redictObject *from_key, *to_key; /* Optional name of key processed, NULL when unknown.
|
||||
In most cases, only 'from_key' is valid, but in callbacks
|
||||
struct redictObject *from_key, *to_key; /* Optional name of key processed, NULL when unknown.
|
||||
In most cases, only 'from_key' is valid, but in callbacks
|
||||
such as `copy2`, both 'from_key' and 'to_key' are valid. */
|
||||
int from_dbid, to_dbid; /* The dbid of the key being processed, -1 when unknown.
|
||||
In most cases, only 'from_dbid' is valid, but in callbacks such
|
||||
In most cases, only 'from_dbid' is valid, but in callbacks such
|
||||
as `copy2`, 'from_dbid' and 'to_dbid' are both valid. */
|
||||
} RedictModuleKeyOptCtx;
|
||||
|
||||
/* Data structures related to redis module configurations */
|
||||
/* Data structures related to redict module configurations */
|
||||
/* The function signatures for module config get callbacks. These are identical to the ones exposed in redictmodule.h. */
|
||||
typedef RedictModuleString * (*RedictModuleConfigGetStringFunc)(const char *name, void *privdata);
|
||||
typedef long long (*RedictModuleConfigGetNumericFunc)(const char *name, void *privdata);
|
||||
@ -1022,14 +1022,14 @@ int RM_IsChannelsPositionRequest(RedictModuleCtx *ctx) {
|
||||
* registration, the command implementation checks for this special call
|
||||
* using the RedictModule_IsChannelsPositionRequest() API and uses this
|
||||
* function in order to report the channels.
|
||||
*
|
||||
*
|
||||
* The supported flags are:
|
||||
* * REDICTMODULE_CMD_CHANNEL_SUBSCRIBE: This command will subscribe to the channel.
|
||||
* * REDICTMODULE_CMD_CHANNEL_UNSUBSCRIBE: This command will unsubscribe from this channel.
|
||||
* * REDICTMODULE_CMD_CHANNEL_PUBLISH: This command will publish to this channel.
|
||||
* * REDICTMODULE_CMD_CHANNEL_PATTERN: Instead of acting on a specific channel, will act on any
|
||||
* * REDICTMODULE_CMD_CHANNEL_PATTERN: Instead of acting on a specific channel, will act on any
|
||||
* channel specified by the pattern. This is the same access
|
||||
* used by the PSUBSCRIBE and PUNSUBSCRIBE commands available
|
||||
* used by the PSUBSCRIBE and PUNSUBSCRIBE commands available
|
||||
* in Redict. Not intended to be used with PUBLISH permissions.
|
||||
*
|
||||
* The following is an example of how it could be used:
|
||||
@ -1239,11 +1239,11 @@ int RM_CreateCommand(RedictModuleCtx *ctx, const char *name, RedictModuleCmdFunc
|
||||
|
||||
sds declared_name = sdsnew(name);
|
||||
RedictModuleCommand *cp = moduleCreateCommandProxy(ctx->module, declared_name, sdsdup(declared_name), cmdfunc, flags, firstkey, lastkey, keystep);
|
||||
cp->rediscmd->arity = cmdfunc ? -1 : -2; /* Default value, can be changed later via dedicated API */
|
||||
cp->redictcmd->arity = cmdfunc ? -1 : -2; /* Default value, can be changed later via dedicated API */
|
||||
|
||||
serverAssert(dictAdd(server.commands, sdsdup(declared_name), cp->rediscmd) == DICT_OK);
|
||||
serverAssert(dictAdd(server.orig_commands, sdsdup(declared_name), cp->rediscmd) == DICT_OK);
|
||||
cp->rediscmd->id = ACLGetCommandID(declared_name); /* ID used for ACL. */
|
||||
serverAssert(dictAdd(server.commands, sdsdup(declared_name), cp->redictcmd) == DICT_OK);
|
||||
serverAssert(dictAdd(server.orig_commands, sdsdup(declared_name), cp->redictcmd) == DICT_OK);
|
||||
cp->redictcmd->id = ACLGetCommandID(declared_name); /* ID used for ACL. */
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
@ -1255,7 +1255,7 @@ int RM_CreateCommand(RedictModuleCtx *ctx, const char *name, RedictModuleCmdFunc
|
||||
* Function will take the ownership of both 'declared_name' and 'fullname' SDS.
|
||||
*/
|
||||
RedictModuleCommand *moduleCreateCommandProxy(struct RedictModule *module, sds declared_name, sds fullname, RedictModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) {
|
||||
struct redictCommand *rediscmd;
|
||||
struct redictCommand *redictcmd;
|
||||
RedictModuleCommand *cp;
|
||||
|
||||
/* Create a command "proxy", which is a structure that is referenced
|
||||
@ -1265,34 +1265,34 @@ RedictModuleCommand *moduleCreateCommandProxy(struct RedictModule *module, sds d
|
||||
cp = zcalloc(sizeof(*cp));
|
||||
cp->module = module;
|
||||
cp->func = cmdfunc;
|
||||
cp->rediscmd = zcalloc(sizeof(*rediscmd));
|
||||
cp->rediscmd->declared_name = declared_name; /* SDS for module commands */
|
||||
cp->rediscmd->fullname = fullname;
|
||||
cp->rediscmd->group = COMMAND_GROUP_MODULE;
|
||||
cp->rediscmd->proc = RedictModuleCommandDispatcher;
|
||||
cp->rediscmd->flags = flags | CMD_MODULE;
|
||||
cp->rediscmd->module_cmd = cp;
|
||||
cp->redictcmd = zcalloc(sizeof(*redictcmd));
|
||||
cp->redictcmd->declared_name = declared_name; /* SDS for module commands */
|
||||
cp->redictcmd->fullname = fullname;
|
||||
cp->redictcmd->group = COMMAND_GROUP_MODULE;
|
||||
cp->redictcmd->proc = RedictModuleCommandDispatcher;
|
||||
cp->redictcmd->flags = flags | CMD_MODULE;
|
||||
cp->redictcmd->module_cmd = cp;
|
||||
if (firstkey != 0) {
|
||||
cp->rediscmd->key_specs_num = 1;
|
||||
cp->rediscmd->key_specs = zcalloc(sizeof(keySpec));
|
||||
cp->rediscmd->key_specs[0].flags = CMD_KEY_FULL_ACCESS;
|
||||
cp->redictcmd->key_specs_num = 1;
|
||||
cp->redictcmd->key_specs = zcalloc(sizeof(keySpec));
|
||||
cp->redictcmd->key_specs[0].flags = CMD_KEY_FULL_ACCESS;
|
||||
if (flags & CMD_MODULE_GETKEYS)
|
||||
cp->rediscmd->key_specs[0].flags |= CMD_KEY_VARIABLE_FLAGS;
|
||||
cp->rediscmd->key_specs[0].begin_search_type = KSPEC_BS_INDEX;
|
||||
cp->rediscmd->key_specs[0].bs.index.pos = firstkey;
|
||||
cp->rediscmd->key_specs[0].find_keys_type = KSPEC_FK_RANGE;
|
||||
cp->rediscmd->key_specs[0].fk.range.lastkey = lastkey < 0 ? lastkey : (lastkey-firstkey);
|
||||
cp->rediscmd->key_specs[0].fk.range.keystep = keystep;
|
||||
cp->rediscmd->key_specs[0].fk.range.limit = 0;
|
||||
cp->redictcmd->key_specs[0].flags |= CMD_KEY_VARIABLE_FLAGS;
|
||||
cp->redictcmd->key_specs[0].begin_search_type = KSPEC_BS_INDEX;
|
||||
cp->redictcmd->key_specs[0].bs.index.pos = firstkey;
|
||||
cp->redictcmd->key_specs[0].find_keys_type = KSPEC_FK_RANGE;
|
||||
cp->redictcmd->key_specs[0].fk.range.lastkey = lastkey < 0 ? lastkey : (lastkey-firstkey);
|
||||
cp->redictcmd->key_specs[0].fk.range.keystep = keystep;
|
||||
cp->redictcmd->key_specs[0].fk.range.limit = 0;
|
||||
} else {
|
||||
cp->rediscmd->key_specs_num = 0;
|
||||
cp->rediscmd->key_specs = NULL;
|
||||
cp->redictcmd->key_specs_num = 0;
|
||||
cp->redictcmd->key_specs = NULL;
|
||||
}
|
||||
populateCommandLegacyRangeSpec(cp->rediscmd);
|
||||
cp->rediscmd->microseconds = 0;
|
||||
cp->rediscmd->calls = 0;
|
||||
cp->rediscmd->rejected_calls = 0;
|
||||
cp->rediscmd->failed_calls = 0;
|
||||
populateCommandLegacyRangeSpec(cp->redictcmd);
|
||||
cp->redictcmd->microseconds = 0;
|
||||
cp->redictcmd->calls = 0;
|
||||
cp->redictcmd->rejected_calls = 0;
|
||||
cp->redictcmd->failed_calls = 0;
|
||||
return cp;
|
||||
}
|
||||
|
||||
@ -1353,7 +1353,7 @@ int RM_CreateSubcommand(RedictModuleCommand *parent, const char *name, RedictMod
|
||||
if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
struct redictCommand *parent_cmd = parent->rediscmd;
|
||||
struct redictCommand *parent_cmd = parent->redictcmd;
|
||||
|
||||
if (parent_cmd->parent)
|
||||
return REDICTMODULE_ERR; /* We don't allow more than one level of subcommands */
|
||||
@ -1375,9 +1375,9 @@ int RM_CreateSubcommand(RedictModuleCommand *parent, const char *name, RedictMod
|
||||
|
||||
sds fullname = catSubCommandFullname(parent_cmd->fullname, name);
|
||||
RedictModuleCommand *cp = moduleCreateCommandProxy(parent->module, declared_name, fullname, cmdfunc, flags, firstkey, lastkey, keystep);
|
||||
cp->rediscmd->arity = -2;
|
||||
cp->redictcmd->arity = -2;
|
||||
|
||||
commandAddSubcommand(parent_cmd, cp->rediscmd, name);
|
||||
commandAddSubcommand(parent_cmd, cp->redictcmd, name);
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
@ -1419,13 +1419,13 @@ int populateArgsStructure(struct redictCommandArg *args) {
|
||||
|
||||
/* RedictModule_AddACLCategory can be used to add new ACL command categories. Category names
|
||||
* can only contain alphanumeric characters, underscores, or dashes. Categories can only be added
|
||||
* during the RedictModule_OnLoad function. Once a category has been added, it can not be removed.
|
||||
* during the RedictModule_OnLoad function. Once a category has been added, it can not be removed.
|
||||
* Any module can register a command to any added categories using RedictModule_SetCommandACLCategories.
|
||||
*
|
||||
*
|
||||
* Returns:
|
||||
* - REDICTMODULE_OK on successfully adding the new ACL category.
|
||||
* - REDICTMODULE_OK on successfully adding the new ACL category.
|
||||
* - REDICTMODULE_ERR on failure.
|
||||
*
|
||||
*
|
||||
* On error the errno is set to:
|
||||
* - EINVAL if the name contains invalid characters.
|
||||
* - EBUSY if the category name already exists.
|
||||
@ -1471,9 +1471,9 @@ int matchAclCategoryFlag(char *flag, int64_t *acl_categories_flags) {
|
||||
}
|
||||
|
||||
/* Helper for RM_SetCommandACLCategories(). Turns a string representing acl category
|
||||
* flags into the acl category flags used by Redict ACL which allows users to access
|
||||
* flags into the acl category flags used by Redict ACL which allows users to access
|
||||
* the module commands by acl categories.
|
||||
*
|
||||
*
|
||||
* It returns the set of acl flags, or -1 if unknown flags are found. */
|
||||
int64_t categoryFlagsFromString(char *aclflags) {
|
||||
int count, j;
|
||||
@ -1494,12 +1494,12 @@ int64_t categoryFlagsFromString(char *aclflags) {
|
||||
/* RedictModule_SetCommandACLCategories can be used to set ACL categories to module
|
||||
* commands and subcommands. The set of ACL categories should be passed as
|
||||
* a space separated C string 'aclflags'.
|
||||
*
|
||||
* Example, the acl flags 'write slow' marks the command as part of the write and
|
||||
*
|
||||
* Example, the acl flags 'write slow' marks the command as part of the write and
|
||||
* slow ACL categories.
|
||||
*
|
||||
*
|
||||
* On success REDICTMODULE_OK is returned. On error REDICTMODULE_ERR is returned.
|
||||
*
|
||||
*
|
||||
* This function can only be called during the RedictModule_OnLoad function. If called
|
||||
* outside of this function, an error is returned.
|
||||
*/
|
||||
@ -1507,7 +1507,7 @@ int RM_SetCommandACLCategories(RedictModuleCommand *command, const char *aclflag
|
||||
if (!command || !command->module || !command->module->onload) return REDICTMODULE_ERR;
|
||||
int64_t categories_flags = aclflags ? categoryFlagsFromString((char*)aclflags) : 0;
|
||||
if (categories_flags == -1) return REDICTMODULE_ERR;
|
||||
struct redictCommand *rcmd = command->rediscmd;
|
||||
struct redictCommand *rcmd = command->redictcmd;
|
||||
rcmd->acl_categories = categories_flags; /* ACL categories flags for module command */
|
||||
command->module->num_commands_with_acl_categories++;
|
||||
return REDICTMODULE_OK;
|
||||
@ -1731,7 +1731,7 @@ int RM_SetCommandACLCategories(RedictModuleCommand *command, const char *aclflag
|
||||
*
|
||||
* Other flags:
|
||||
*
|
||||
* * `REDICTMODULE_CMD_KEY_NOT_KEY`: The key is not actually a key, but
|
||||
* * `REDICTMODULE_CMD_KEY_NOT_KEY`: The key is not actually a key, but
|
||||
* should be routed in cluster mode as if it was a key.
|
||||
*
|
||||
* * `REDICTMODULE_CMD_KEY_INCOMPLETE`: The keyspec might not point out all
|
||||
@ -1820,7 +1820,7 @@ int RM_SetCommandInfo(RedictModuleCommand *command, const RedictModuleCommandInf
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
struct redictCommand *cmd = command->rediscmd;
|
||||
struct redictCommand *cmd = command->redictcmd;
|
||||
|
||||
/* Check if any info has already been set. Overwriting info involves freeing
|
||||
* the old info, which is not implemented. */
|
||||
@ -1992,7 +1992,7 @@ static int moduleValidateCommandInfo(const RedictModuleCommandInfo *info) {
|
||||
moduleCmdKeySpecAt(version, info->key_specs, j);
|
||||
if (j >= INT_MAX) {
|
||||
serverLog(LL_WARNING, "Invalid command info: Too many key specs");
|
||||
return 0; /* redisCommand.key_specs_num is an int. */
|
||||
return 0; /* redictCommand.key_specs_num is an int. */
|
||||
}
|
||||
|
||||
/* Flags. Exactly one flag in a group is set if and only if the
|
||||
@ -2305,7 +2305,7 @@ ustime_t RM_CachedMicroseconds(void) {
|
||||
* RM_BlockedClientMeasureTimeStart() and RM_BlockedClientMeasureTimeEnd()
|
||||
* to accumulate independent time intervals to the background duration.
|
||||
* This method always return REDICTMODULE_OK.
|
||||
*
|
||||
*
|
||||
* This function is not thread safe, If used in module thread and blocked callback (possibly main thread)
|
||||
* simultaneously, it's recommended to protect them with lock owned by caller instead of GIL. */
|
||||
int RM_BlockedClientMeasureTimeStart(RedictModuleBlockedClient *bc) {
|
||||
@ -2318,7 +2318,7 @@ int RM_BlockedClientMeasureTimeStart(RedictModuleBlockedClient *bc) {
|
||||
* On success REDICTMODULE_OK is returned.
|
||||
* This method only returns REDICTMODULE_ERR if no start time was
|
||||
* previously defined ( meaning RM_BlockedClientMeasureTimeStart was not called ).
|
||||
*
|
||||
*
|
||||
* This function is not thread safe, If used in module thread and blocked callback (possibly main thread)
|
||||
* simultaneously, it's recommended to protect them with lock owned by caller instead of GIL. */
|
||||
int RM_BlockedClientMeasureTimeEnd(RedictModuleBlockedClient *bc) {
|
||||
@ -2360,10 +2360,10 @@ void RM_Yield(RedictModuleCtx *ctx, int flags, const char *busy_reply) {
|
||||
long long now = getMonotonicUs();
|
||||
if (now >= ctx->next_yield_time) {
|
||||
/* In loading mode, there's no need to handle busy_module_yield_reply,
|
||||
* and busy_module_yield_flags, since redis is anyway rejecting all
|
||||
* and busy_module_yield_flags, since redict is anyway rejecting all
|
||||
* commands with -LOADING. */
|
||||
if (server.loading) {
|
||||
/* Let redis process events */
|
||||
/* Let redict process events */
|
||||
processEventsWhileBlocked();
|
||||
} else {
|
||||
const char *prev_busy_module_yield_reply = server.busy_module_yield_reply;
|
||||
@ -2378,7 +2378,7 @@ void RM_Yield(RedictModuleCtx *ctx, int flags, const char *busy_reply) {
|
||||
if (flags & REDICTMODULE_YIELD_FLAG_CLIENTS)
|
||||
server.busy_module_yield_flags |= BUSY_MODULE_YIELD_CLIENTS;
|
||||
|
||||
/* Let redis process events */
|
||||
/* Let redict process events */
|
||||
if (!pthread_equal(server.main_thread_id, pthread_self())) {
|
||||
/* If we are not in the main thread, we defer event loop processing to the main thread
|
||||
* after the main thread enters acquiring GIL state in order to protect the event
|
||||
@ -2432,10 +2432,10 @@ void RM_Yield(RedictModuleCtx *ctx, int flags, const char *busy_reply) {
|
||||
*
|
||||
* REDICTMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED:
|
||||
* See RM_SignalModifiedKey().
|
||||
*
|
||||
*
|
||||
* REDICTMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD:
|
||||
* Setting this flag indicates module awareness of diskless async replication (repl-diskless-load=swapdb)
|
||||
* and that redis could be serving reads during replication instead of blocking with LOADING status.
|
||||
* and that redict could be serving reads during replication instead of blocking with LOADING status.
|
||||
*
|
||||
* REDICTMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS:
|
||||
* Declare that the module wants to get nested key-space notifications.
|
||||
@ -3166,9 +3166,9 @@ int RM_ReplyWithArray(RedictModuleCtx *ctx, long len) {
|
||||
*
|
||||
* If the connected client is using RESP2, the reply will be converted to a flat
|
||||
* array.
|
||||
*
|
||||
*
|
||||
* Use RM_ReplySetMapLength() to set deferred length.
|
||||
*
|
||||
*
|
||||
* The function always returns REDICTMODULE_OK. */
|
||||
int RM_ReplyWithMap(RedictModuleCtx *ctx, long len) {
|
||||
return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_MAP);
|
||||
@ -3185,7 +3185,7 @@ int RM_ReplyWithMap(RedictModuleCtx *ctx, long len) {
|
||||
* array type.
|
||||
*
|
||||
* Use RM_ReplySetSetLength() to set deferred length.
|
||||
*
|
||||
*
|
||||
* The function always returns REDICTMODULE_OK. */
|
||||
int RM_ReplyWithSet(RedictModuleCtx *ctx, long len) {
|
||||
return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_SET);
|
||||
@ -3200,12 +3200,12 @@ int RM_ReplyWithSet(RedictModuleCtx *ctx, long len) {
|
||||
* See Reply APIs section for more details.
|
||||
*
|
||||
* Use RM_ReplySetAttributeLength() to set deferred length.
|
||||
*
|
||||
*
|
||||
* Not supported by RESP2 and will return REDICTMODULE_ERR, otherwise
|
||||
* the function always returns REDICTMODULE_OK. */
|
||||
int RM_ReplyWithAttribute(RedictModuleCtx *ctx, long len) {
|
||||
if (ctx->client->resp == 2) return REDICTMODULE_ERR;
|
||||
|
||||
|
||||
return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_ATTRIBUTE);
|
||||
}
|
||||
|
||||
@ -3449,7 +3449,7 @@ int RM_ReplyWithCallReply(RedictModuleCtx *ctx, RedictModuleCallReply *reply) {
|
||||
* a string into a C buffer, and then calling the function
|
||||
* RedictModule_ReplyWithStringBuffer() with the buffer and length.
|
||||
*
|
||||
* In RESP3 the string is tagged as a double, while in RESP2 it's just a plain string
|
||||
* In RESP3 the string is tagged as a double, while in RESP2 it's just a plain string
|
||||
* that the user will have to parse.
|
||||
*
|
||||
* The function always returns REDICTMODULE_OK. */
|
||||
@ -3463,7 +3463,7 @@ int RM_ReplyWithDouble(RedictModuleCtx *ctx, double d) {
|
||||
/* Reply with a RESP3 BigNumber type.
|
||||
* Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3.
|
||||
*
|
||||
* In RESP3, this is a string of length `len` that is tagged as a BigNumber,
|
||||
* In RESP3, this is a string of length `len` that is tagged as a BigNumber,
|
||||
* however, it's up to the caller to ensure that it's a valid BigNumber.
|
||||
* In RESP2, this is just a plain bulk string response.
|
||||
*
|
||||
@ -3619,7 +3619,7 @@ RedictModuleString *RM_GetClientUserNameById(RedictModuleCtx *ctx, uint64_t id)
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (client->user == NULL) {
|
||||
errno = ENOTSUP;
|
||||
return NULL;
|
||||
@ -4069,7 +4069,7 @@ RedictModuleKey *RM_OpenKey(RedictModuleCtx *ctx, robj *keyname, int mode) {
|
||||
/**
|
||||
* Returns the full OpenKey modes mask, using the return value
|
||||
* the module can check if a certain set of OpenKey modes are supported
|
||||
* by the redis server version in use.
|
||||
* by the redict server version in use.
|
||||
* Example:
|
||||
*
|
||||
* int supportedMode = RM_GetOpenKeyModesAll();
|
||||
@ -4221,7 +4221,7 @@ mstime_t RM_GetAbsExpire(RedictModuleKey *key) {
|
||||
/* Set a new expire for the key. If the special expire
|
||||
* REDICTMODULE_NO_EXPIRE is set, the expire is cancelled if there was
|
||||
* one (the same as the PERSIST command).
|
||||
*
|
||||
*
|
||||
* Note that the expire must be provided as a positive integer representing
|
||||
* the absolute Unix timestamp the key should have.
|
||||
*
|
||||
@ -4725,7 +4725,7 @@ int moduleZsetAddFlagsFromCoreFlags(int flags) {
|
||||
*
|
||||
* REDICTMODULE_ZADD_XX: Element must already exist. Do nothing otherwise.
|
||||
* REDICTMODULE_ZADD_NX: Element must not exist. Do nothing otherwise.
|
||||
* REDICTMODULE_ZADD_GT: If element exists, new score must be greater than the current score.
|
||||
* REDICTMODULE_ZADD_GT: If element exists, new score must be greater than the current score.
|
||||
* Do nothing otherwise. Can optionally be combined with XX.
|
||||
* REDICTMODULE_ZADD_LT: If element exists, new score must be less than the current score.
|
||||
* Do nothing otherwise. Can optionally be combined with XX.
|
||||
@ -6751,7 +6751,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj
|
||||
} else {
|
||||
newval = mt->copy(fromkey, tokey, mv->value);
|
||||
}
|
||||
|
||||
|
||||
if (!newval) {
|
||||
addReplyError(c, "module key failed to copy");
|
||||
return NULL;
|
||||
@ -6801,7 +6801,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj
|
||||
* .unlink = myType_UnlinkCallBack,
|
||||
* .copy = myType_CopyCallback,
|
||||
* .defrag = myType_DefragCallback
|
||||
*
|
||||
*
|
||||
* // Enhanced optional fields
|
||||
* .mem_usage2 = myType_MemUsageCallBack2,
|
||||
* .free_effort2 = myType_FreeEffortCallBack2,
|
||||
@ -6820,11 +6820,11 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj
|
||||
* Similar to aux_save, returns REDICTMODULE_OK on success, and ERR otherwise.
|
||||
* * **free_effort**: A callback function pointer that used to determine whether the module's
|
||||
* memory needs to be lazy reclaimed. The module should return the complexity involved by
|
||||
* freeing the value. for example: how many pointers are gonna be freed. Note that if it
|
||||
* freeing the value. for example: how many pointers are gonna be freed. Note that if it
|
||||
* returns 0, we'll always do an async free.
|
||||
* * **unlink**: A callback function pointer that used to notifies the module that the key has
|
||||
* been removed from the DB by redis, and may soon be freed by a background thread. Note that
|
||||
* it won't be called on FLUSHALL/FLUSHDB (both sync and async), and the module can use the
|
||||
* * **unlink**: A callback function pointer that used to notifies the module that the key has
|
||||
* been removed from the DB by redict, and may soon be freed by a background thread. Note that
|
||||
* it won't be called on FLUSHALL/FLUSHDB (both sync and async), and the module can use the
|
||||
* RedictModuleEvent_FlushDB to hook into that.
|
||||
* * **copy**: A callback function pointer that is used to make a copy of the specified key.
|
||||
* The module is expected to perform a deep copy of the specified value and return it.
|
||||
@ -6832,7 +6832,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj
|
||||
* A NULL return value is considered an error and the copy operation fails.
|
||||
* Note: if the target key exists and is being overwritten, the copy callback will be
|
||||
* called first, followed by a free callback to the value that is being replaced.
|
||||
*
|
||||
*
|
||||
* * **defrag**: A callback function pointer that is used to request the module to defrag
|
||||
* a key. The module should then iterate pointers and call the relevant RM_Defrag*()
|
||||
* functions to defragment pointers or complex types. The module should continue
|
||||
@ -6860,7 +6860,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj
|
||||
* * **aux_save2**: Similar to `aux_save`, but with small semantic change, if the module
|
||||
* saves nothing on this callback then no data about this aux field will be written to the
|
||||
* RDB and it will be possible to load the RDB even if the module is not loaded.
|
||||
*
|
||||
*
|
||||
* Note: the module name "AAAAAAAAA" is reserved and produces an error, it
|
||||
* happens to be pretty lame as well.
|
||||
*
|
||||
@ -7429,7 +7429,7 @@ void *RM_LoadDataTypeFromStringEncver(const RedictModuleString *str, const modul
|
||||
}
|
||||
|
||||
/* Similar to RM_LoadDataTypeFromStringEncver, original version of the API, kept
|
||||
* for backward compatibility.
|
||||
* for backward compatibility.
|
||||
*/
|
||||
void *RM_LoadDataTypeFromString(const RedictModuleString *str, const moduleType *mt) {
|
||||
return RM_LoadDataTypeFromStringEncver(str, mt, 0);
|
||||
@ -7665,7 +7665,7 @@ int isModuleClientUnblocked(client *c) {
|
||||
* because the client is terminated, but is also called for cleanup when a
|
||||
* client is unblocked in a clean way after replaying.
|
||||
*
|
||||
* What we do here is just to set the client to NULL in the redis module
|
||||
* What we do here is just to set the client to NULL in the redict module
|
||||
* blocked client handle. This way if the client is terminated while there
|
||||
* is a pending threaded operation involving the blocked client, we'll know
|
||||
* that the client no longer exists and no reply callback should be called.
|
||||
@ -8372,7 +8372,7 @@ int moduleBlockedClientMayTimeout(client *c) {
|
||||
/* Called when our client timed out. After this function unblockClient()
|
||||
* is called, and it will invalidate the blocked client. So this function
|
||||
* does not need to do any cleanup. Eventually the module will call the
|
||||
* API to unblock the client and the memory will be released.
|
||||
* API to unblock the client and the memory will be released.
|
||||
*
|
||||
* If this function is called from a module, we handle the timeout callback
|
||||
* and the update of the unblock status in a thread-safe manner to avoid race
|
||||
@ -8653,7 +8653,7 @@ void moduleReleaseGIL(void) {
|
||||
* time. The event string is the actual command being executed, and key is the
|
||||
* relevant Redict key.
|
||||
*
|
||||
* Notification callback gets executed with a redis context that can not be
|
||||
* Notification callback gets executed with a redict context that can not be
|
||||
* used to send anything to the client, and has the db number where the event
|
||||
* occurred as its selected db number.
|
||||
*
|
||||
@ -9581,7 +9581,7 @@ int RM_FreeModuleUser(RedictModuleUser *user) {
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
/* Sets the permissions of a user created through the redis module
|
||||
/* Sets the permissions of a user created through the redict module
|
||||
* interface. The syntax is the same as ACL SETUSER, so refer to the
|
||||
* documentation in acl.c for more information. See RM_CreateModuleUser
|
||||
* for detailed usage.
|
||||
@ -9593,7 +9593,7 @@ int RM_SetModuleUserACL(RedictModuleUser *user, const char* acl) {
|
||||
}
|
||||
|
||||
/* Sets the permission of a user with a complete ACL string, such as one
|
||||
* would use on the redis ACL SETUSER command line API. This differs from
|
||||
* would use on the redict ACL SETUSER command line API. This differs from
|
||||
* RM_SetModuleUserACL, which only takes single ACL operations at a time.
|
||||
*
|
||||
* Returns REDICTMODULE_OK on success and REDICTMODULE_ERR on failure
|
||||
@ -9697,13 +9697,13 @@ int RM_ACLCheckCommandPermissions(RedictModuleUser *user, RedictModuleString **a
|
||||
* keyspec for logical operations. These flags are documented in RedictModule_SetCommandInfo as
|
||||
* the REDICTMODULE_CMD_KEY_ACCESS, REDICTMODULE_CMD_KEY_UPDATE, REDICTMODULE_CMD_KEY_INSERT,
|
||||
* and REDICTMODULE_CMD_KEY_DELETE flags.
|
||||
*
|
||||
*
|
||||
* If no flags are supplied, the user is still required to have some access to the key for
|
||||
* this command to return successfully.
|
||||
*
|
||||
* If the user is able to access the key then REDICTMODULE_OK is returned, otherwise
|
||||
* REDICTMODULE_ERR is returned and errno is set to one of the following values:
|
||||
*
|
||||
*
|
||||
* * EINVAL: The provided flags are invalid.
|
||||
* * EACCESS: The user does not have permission to access the key.
|
||||
*/
|
||||
@ -9733,9 +9733,9 @@ int RM_ACLCheckKeyPermissions(RedictModuleUser *user, RedictModuleString *key, i
|
||||
*
|
||||
* If the user is able to access the pubsub channel then REDICTMODULE_OK is returned, otherwise
|
||||
* REDICTMODULE_ERR is returned and errno is set to one of the following values:
|
||||
*
|
||||
*
|
||||
* * EINVAL: The provided flags are invalid.
|
||||
* * EACCESS: The user does not have permission to access the pubsub channel.
|
||||
* * EACCESS: The user does not have permission to access the pubsub channel.
|
||||
*/
|
||||
int RM_ACLCheckChannelPermissions(RedictModuleUser *user, RedictModuleString *ch, int flags) {
|
||||
const int allow_mask = (REDICTMODULE_CMD_CHANNEL_PUBLISH
|
||||
@ -9848,7 +9848,7 @@ static int authenticateClientWithUser(RedictModuleCtx *ctx, user *user, RedictMo
|
||||
}
|
||||
|
||||
|
||||
/* Authenticate the current context's user with the provided redis acl user.
|
||||
/* Authenticate the current context's user with the provided redict acl user.
|
||||
* Returns REDICTMODULE_ERR if the user is disabled.
|
||||
*
|
||||
* See authenticateClientWithUser for information about callback, client_id,
|
||||
@ -9857,7 +9857,7 @@ int RM_AuthenticateClientWithUser(RedictModuleCtx *ctx, RedictModuleUser *module
|
||||
return authenticateClientWithUser(ctx, module_user->user, callback, privdata, client_id);
|
||||
}
|
||||
|
||||
/* Authenticate the current context's user with the provided redis acl user.
|
||||
/* Authenticate the current context's user with the provided redict acl user.
|
||||
* Returns REDICTMODULE_ERR if the user is disabled or the user does not exist.
|
||||
*
|
||||
* See authenticateClientWithUser for information about callback, client_id,
|
||||
@ -9893,15 +9893,15 @@ int RM_DeauthenticateAndCloseClient(RedictModuleCtx *ctx, uint64_t client_id) {
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
/* Redact the client command argument specified at the given position. Redacted arguments
|
||||
/* Redact the client command argument specified at the given position. Redacted arguments
|
||||
* are obfuscated in user facing commands such as SLOWLOG or MONITOR, as well as
|
||||
* never being written to server logs. This command may be called multiple times on the
|
||||
* same position.
|
||||
*
|
||||
* Note that the command name, position 0, can not be redacted.
|
||||
*
|
||||
* Returns REDICTMODULE_OK if the argument was redacted and REDICTMODULE_ERR if there
|
||||
* was an invalid parameter passed in or the position is outside the client
|
||||
*
|
||||
* Note that the command name, position 0, can not be redacted.
|
||||
*
|
||||
* Returns REDICTMODULE_OK if the argument was redacted and REDICTMODULE_ERR if there
|
||||
* was an invalid parameter passed in or the position is outside the client
|
||||
* argument range. */
|
||||
int RM_RedactClientCommandArgument(RedictModuleCtx *ctx, int pos) {
|
||||
if (!ctx || !ctx->client || pos <= 0 || ctx->client->argc <= pos) {
|
||||
@ -10679,7 +10679,7 @@ int moduleUnregisterFilters(RedictModule *module) {
|
||||
*
|
||||
* 1. Invocation by a client.
|
||||
* 2. Invocation through `RedictModule_Call()` by any module.
|
||||
* 3. Invocation through Lua `redis.call()`.
|
||||
* 3. Invocation through Lua `redict.call()`.
|
||||
* 4. Replication of a command from a master.
|
||||
*
|
||||
* The filter executes in a special filter context, which is different and more
|
||||
@ -10971,7 +10971,7 @@ void RM_ScanCursorDestroy(RedictModuleScanCursor *cursor) {
|
||||
* void scan_callback(RedictModuleCtx *ctx, RedictModuleString *keyname,
|
||||
* RedictModuleKey *key, void *privdata);
|
||||
*
|
||||
* - `ctx`: the redis module context provided to for the scan.
|
||||
* - `ctx`: the redict module context provided to for the scan.
|
||||
* - `keyname`: owned by the caller and need to be retained if used after this
|
||||
* function.
|
||||
* - `key`: holds info on the key and value, it is provided as best effort, in
|
||||
@ -11069,7 +11069,7 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) {
|
||||
*
|
||||
* void scan_callback(RedictModuleKey *key, RedictModuleString* field, RedictModuleString* value, void *privdata);
|
||||
*
|
||||
* - key - the redis key context provided to for the scan.
|
||||
* - key - the redict key context provided to for the scan.
|
||||
* - field - field name, owned by the caller and need to be retained if used
|
||||
* after this function.
|
||||
* - value - value string or NULL for set type, owned by the caller and need to
|
||||
@ -11519,13 +11519,13 @@ static uint64_t moduleEventVersions[] = {
|
||||
* int32_t dbnum_second; // Swap Db second dbnum
|
||||
*
|
||||
* * RedictModuleEvent_ReplBackup
|
||||
*
|
||||
*
|
||||
* WARNING: Replication Backup events are deprecated since Redis 7.0 and are never fired.
|
||||
* See RedictModuleEvent_ReplAsyncLoad for understanding how Async Replication Loading events
|
||||
* are now triggered when repl-diskless-load is set to swapdb.
|
||||
*
|
||||
* Called when repl-diskless-load config is set to swapdb,
|
||||
* And redis needs to backup the current database for the
|
||||
* And redict needs to backup the current database for the
|
||||
* possibility to be restored later. A module with global data and
|
||||
* maybe with aux_load and aux_save callbacks may need to use this
|
||||
* notification to backup / restore / discard its globals.
|
||||
@ -11534,12 +11534,12 @@ static uint64_t moduleEventVersions[] = {
|
||||
* * `REDICTMODULE_SUBEVENT_REPL_BACKUP_CREATE`
|
||||
* * `REDICTMODULE_SUBEVENT_REPL_BACKUP_RESTORE`
|
||||
* * `REDICTMODULE_SUBEVENT_REPL_BACKUP_DISCARD`
|
||||
*
|
||||
*
|
||||
* * RedictModuleEvent_ReplAsyncLoad
|
||||
*
|
||||
* Called when repl-diskless-load config is set to swapdb and a replication with a master of same
|
||||
* data set history (matching replication ID) occurs.
|
||||
* In which case redis serves current data set while loading new database in memory from socket.
|
||||
* In which case redict serves current data set while loading new database in memory from socket.
|
||||
* Modules must have declared they support this mechanism in order to activate it, through
|
||||
* REDICTMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD flag.
|
||||
* The following sub events are available:
|
||||
@ -11576,7 +11576,7 @@ static uint64_t moduleEventVersions[] = {
|
||||
* structure with the following fields:
|
||||
*
|
||||
* const char **config_names; // An array of C string pointers containing the
|
||||
* // name of each modified configuration item
|
||||
* // name of each modified configuration item
|
||||
* uint32_t num_changes; // The number of elements in the config_names array
|
||||
*
|
||||
* * RedictModule_Event_Key
|
||||
@ -11673,7 +11673,7 @@ int RM_IsSubEventSupported(RedictModuleEvent event, int64_t subevent) {
|
||||
case REDICTMODULE_EVENT_EVENTLOOP:
|
||||
return subevent < _REDICTMODULE_SUBEVENT_EVENTLOOP_NEXT;
|
||||
case REDICTMODULE_EVENT_CONFIG:
|
||||
return subevent < _REDICTMODULE_SUBEVENT_CONFIG_NEXT;
|
||||
return subevent < _REDICTMODULE_SUBEVENT_CONFIG_NEXT;
|
||||
case REDICTMODULE_EVENT_KEY:
|
||||
return subevent < _REDICTMODULE_SUBEVENT_KEY_NEXT;
|
||||
default:
|
||||
@ -11845,7 +11845,7 @@ void moduleNotifyKeyUnlink(robj *key, robj *val, int dbid, int flags) {
|
||||
server.lazy_expire_disabled--;
|
||||
}
|
||||
|
||||
/* Return the free_effort of the module, it will automatically choose to call
|
||||
/* Return the free_effort of the module, it will automatically choose to call
|
||||
* `free_effort` or `free_effort2`, and the default return value is 1.
|
||||
* value of 0 means very high effort (always asynchronous freeing). */
|
||||
size_t moduleGetFreeEffort(robj *key, robj *val, int dbid) {
|
||||
@ -11858,12 +11858,12 @@ size_t moduleGetFreeEffort(robj *key, robj *val, int dbid) {
|
||||
effort = mt->free_effort2(&ctx,mv->value);
|
||||
} else if (mt->free_effort != NULL) {
|
||||
effort = mt->free_effort(key,mv->value);
|
||||
}
|
||||
}
|
||||
|
||||
return effort;
|
||||
}
|
||||
|
||||
/* Return the memory usage of the module, it will automatically choose to call
|
||||
/* Return the memory usage of the module, it will automatically choose to call
|
||||
* `mem_usage` or `mem_usage2`, and the default return value is 0. */
|
||||
size_t moduleGetMemUsage(robj *key, robj *val, size_t sample_size, int dbid) {
|
||||
moduleValue *mv = val->ptr;
|
||||
@ -11875,7 +11875,7 @@ size_t moduleGetMemUsage(robj *key, robj *val, size_t sample_size, int dbid) {
|
||||
size = mt->mem_usage2(&ctx, mv->value, sample_size);
|
||||
} else if (mt->mem_usage != NULL) {
|
||||
size = mt->mem_usage(mv->value);
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
@ -11955,11 +11955,11 @@ void moduleInitModulesSystem(void) {
|
||||
|
||||
moduleRegisterCoreAPI();
|
||||
|
||||
/* Create a pipe for module threads to be able to wake up the redis main thread.
|
||||
/* Create a pipe for module threads to be able to wake up the redict main thread.
|
||||
* Make the pipe non blocking. This is just a best effort aware mechanism
|
||||
* and we do not want to block not in the read nor in the write half.
|
||||
* Enable close-on-exec flag on pipes in case of the fork-exec system calls in
|
||||
* sentinels or redis servers. */
|
||||
* sentinels or redict servers. */
|
||||
if (anetPipe(server.module_pipe, O_CLOEXEC|O_NONBLOCK, O_CLOEXEC|O_NONBLOCK) == -1) {
|
||||
serverLog(LL_WARNING,
|
||||
"Can't create the pipe for module threads: %s", strerror(errno));
|
||||
@ -12288,7 +12288,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa
|
||||
incrRefCount(ctx.module->loadmod->argv[i]);
|
||||
}
|
||||
|
||||
/* If module commands have ACL categories, recompute command bits
|
||||
/* If module commands have ACL categories, recompute command bits
|
||||
* for all existing users once the modules has been registered. */
|
||||
if (ctx.module->num_commands_with_acl_categories) {
|
||||
ACLRecomputeCommandBitsFromCommandRulesAllUsers();
|
||||
@ -12498,7 +12498,7 @@ sds genModulesInfoString(sds info) {
|
||||
/* --------------------------------------------------------------------------
|
||||
* Module Configurations API internals
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/* Check if the configuration name is already registered */
|
||||
int isModuleConfigNameRegistered(RedictModule *module, const char *name) {
|
||||
listNode *match = listSearchKey(module->module_configs, (void *) name);
|
||||
@ -12551,7 +12551,7 @@ int moduleVerifyResourceName(const char *name) {
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
/* This is a series of set functions for each type that act as dispatchers for
|
||||
/* This is a series of set functions for each type that act as dispatchers for
|
||||
* config.c to call module set callbacks. */
|
||||
#define CONFIG_ERR_SIZE 256
|
||||
static char configerr[CONFIG_ERR_SIZE];
|
||||
@ -12593,7 +12593,7 @@ int setModuleNumericConfig(ModuleConfig *config, long long val, const char **err
|
||||
return return_code == REDICTMODULE_OK ? 1 : 0;
|
||||
}
|
||||
|
||||
/* This is a series of get functions for each type that act as dispatchers for
|
||||
/* This is a series of get functions for each type that act as dispatchers for
|
||||
* config.c to call module set callbacks. */
|
||||
int getModuleBoolConfig(ModuleConfig *module_config) {
|
||||
return module_config->get_fn.get_bool(module_config->name, module_config->privdata);
|
||||
@ -12764,7 +12764,7 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) {
|
||||
* The `setfn` callback is expected to return REDICTMODULE_OK when the value is successfully
|
||||
* applied. It can also return REDICTMODULE_ERR if the value can't be applied, and the
|
||||
* *err pointer can be set with a RedictModuleString error message to provide to the client.
|
||||
* This RedictModuleString will be freed by redis after returning from the set callback.
|
||||
* This RedictModuleString will be freed by redict after returning from the set callback.
|
||||
*
|
||||
* All configs are registered with a name, a type, a default value, private data that is made
|
||||
* available in the callbacks, as well as several flags that modify the behavior of the config.
|
||||
@ -12827,8 +12827,8 @@ int RM_RegisterStringConfig(RedictModuleCtx *ctx, const char *name, const char *
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
/* Create a bool config that server clients can interact with via the
|
||||
* `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See
|
||||
/* Create a bool config that server clients can interact with via the
|
||||
* `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See
|
||||
* RedictModule_RegisterStringConfig for detailed information about configs. */
|
||||
int RM_RegisterBoolConfig(RedictModuleCtx *ctx, const char *name, int default_val, unsigned int flags, RedictModuleConfigGetBoolFunc getfn, RedictModuleConfigSetBoolFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) {
|
||||
RedictModule *module = ctx->module;
|
||||
@ -12844,10 +12844,10 @@ int RM_RegisterBoolConfig(RedictModuleCtx *ctx, const char *name, int default_va
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an enum config that server clients can interact with via the
|
||||
* `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands.
|
||||
* Enum configs are a set of string tokens to corresponding integer values, where
|
||||
/*
|
||||
* Create an enum config that server clients can interact with via the
|
||||
* `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands.
|
||||
* Enum configs are a set of string tokens to corresponding integer values, where
|
||||
* the string value is exposed to Redict clients but the value passed Redict and the
|
||||
* module is the integer value. These values are defined in enum_values, an array
|
||||
* of null-terminated c strings, and int_vals, an array of enum values who has an
|
||||
@ -12860,7 +12860,7 @@ int RM_RegisterBoolConfig(RedictModuleCtx *ctx, const char *name, int default_va
|
||||
* int getEnumConfigCommand(const char *name, void *privdata) {
|
||||
* return enum_val;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* int setEnumConfigCommand(const char *name, int val, void *privdata, const char **err) {
|
||||
* enum_val = val;
|
||||
* return REDICTMODULE_OK;
|
||||
@ -12895,8 +12895,8 @@ int RM_RegisterEnumConfig(RedictModuleCtx *ctx, const char *name, int default_va
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an integer config that server clients can interact with via the
|
||||
* `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See
|
||||
* Create an integer config that server clients can interact with via the
|
||||
* `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See
|
||||
* RedictModule_RegisterStringConfig for detailed information about configs. */
|
||||
int RM_RegisterNumericConfig(RedictModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, RedictModuleConfigGetNumericFunc getfn, RedictModuleConfigSetNumericFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) {
|
||||
RedictModule *module = ctx->module;
|
||||
@ -13104,7 +13104,7 @@ NULL
|
||||
argc = c->argc - 3;
|
||||
argv = &c->argv[3];
|
||||
}
|
||||
/* If this is a loadex command we want to populate server.module_configs_queue with
|
||||
/* If this is a loadex command we want to populate server.module_configs_queue with
|
||||
* sds NAME VALUE pairs. We also want to increment argv to just after ARGS, if supplied. */
|
||||
if (parseLoadexArguments((RedictModuleString ***) &argv, &argc) == REDICTMODULE_OK &&
|
||||
moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1) == C_OK)
|
||||
@ -13198,7 +13198,7 @@ int RM_GetLFU(RedictModuleKey *key, long long *lfu_freq) {
|
||||
/**
|
||||
* Returns the full module options flags mask, using the return value
|
||||
* the module can check if a certain set of module options are supported
|
||||
* by the redis server version in use.
|
||||
* by the redict server version in use.
|
||||
* Example:
|
||||
*
|
||||
* int supportedFlags = RM_GetModuleOptionsAll();
|
||||
@ -13215,7 +13215,7 @@ int RM_GetModuleOptionsAll(void) {
|
||||
/**
|
||||
* Returns the full ContextFlags mask, using the return value
|
||||
* the module can check if a certain set of flags are supported
|
||||
* by the redis server version in use.
|
||||
* by the redict server version in use.
|
||||
* Example:
|
||||
*
|
||||
* int supportedFlags = RM_GetContextFlagsAll();
|
||||
@ -13232,7 +13232,7 @@ int RM_GetContextFlagsAll(void) {
|
||||
/**
|
||||
* Returns the full KeyspaceNotification mask, using the return value
|
||||
* the module can check if a certain set of flags are supported
|
||||
* by the redis server version in use.
|
||||
* by the redict server version in use.
|
||||
* Example:
|
||||
*
|
||||
* int supportedFlags = RM_GetKeyspaceNotificationFlagsAll();
|
||||
@ -13247,7 +13247,7 @@ int RM_GetKeyspaceNotificationFlagsAll(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the redis version in format of 0x00MMmmpp.
|
||||
* Return the redict version in format of 0x00MMmmpp.
|
||||
* Example for 6.0.7 the return value will be 0x00060007.
|
||||
*/
|
||||
int RM_GetServerVersion(void) {
|
||||
|
@ -517,7 +517,7 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) {
|
||||
* be sent because addReply*() against master clients has no effect...
|
||||
* A notable example is:
|
||||
*
|
||||
* EVAL 'redis.call("incr",KEYS[1]); redis.call("nonexisting")' 1 x
|
||||
* EVAL 'redict.call("incr",KEYS[1]); redict.call("nonexisting")' 1 x
|
||||
*
|
||||
* Where the master must propagate the first change even if the second
|
||||
* will produce an error. However it is useful to log such events since
|
||||
@ -556,7 +556,7 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) {
|
||||
int panic_in_replicas = (ctype == CLIENT_TYPE_MASTER && server.repl_slave_ro)
|
||||
&& (server.propagation_error_behavior == PROPAGATION_ERR_BEHAVIOR_PANIC ||
|
||||
server.propagation_error_behavior == PROPAGATION_ERR_BEHAVIOR_PANIC_ON_REPLICAS);
|
||||
int panic_in_aof = c->id == CLIENT_ID_AOF
|
||||
int panic_in_aof = c->id == CLIENT_ID_AOF
|
||||
&& server.propagation_error_behavior == PROPAGATION_ERR_BEHAVIOR_PANIC;
|
||||
if (panic_in_replicas || panic_in_aof) {
|
||||
serverPanic("This %s panicked sending an error to its %s"
|
||||
@ -1466,7 +1466,7 @@ void unlinkClient(client *c) {
|
||||
|
||||
/* Remove from the list of pending writes if needed. */
|
||||
if (c->flags & CLIENT_PENDING_WRITE) {
|
||||
serverAssert(&c->clients_pending_write_node.next != NULL ||
|
||||
serverAssert(&c->clients_pending_write_node.next != NULL ||
|
||||
&c->clients_pending_write_node.prev != NULL);
|
||||
listUnlinkNode(server.clients_pending_write, &c->clients_pending_write_node);
|
||||
c->flags &= ~CLIENT_PENDING_WRITE;
|
||||
@ -1534,7 +1534,7 @@ void clearClientConnectionState(client *c) {
|
||||
|
||||
/* Note: lib_name and lib_ver are not reset since they still
|
||||
* represent the client library behind the connection. */
|
||||
|
||||
|
||||
/* Selectively clear state flags not covered above */
|
||||
c->flags &= ~(CLIENT_ASKING|CLIENT_READONLY|CLIENT_REPLY_OFF|
|
||||
CLIENT_REPLY_SKIP_NEXT|CLIENT_NO_TOUCH|CLIENT_NO_EVICT);
|
||||
@ -1808,7 +1808,7 @@ static int _writevToClient(client *c, ssize_t *nwritten) {
|
||||
int iovmax = min(IOV_MAX, c->conn->iovcnt);
|
||||
struct iovec iov[iovmax];
|
||||
size_t iov_bytes_len = 0;
|
||||
/* If the static reply buffer is not empty,
|
||||
/* If the static reply buffer is not empty,
|
||||
* add it to the iov array for writev() as well. */
|
||||
if (c->bufpos > 0) {
|
||||
iov[iovcnt].iov_base = c->buf + c->sentlen;
|
||||
@ -1924,7 +1924,7 @@ int _writeToClient(client *c, ssize_t *nwritten) {
|
||||
c->bufpos = 0;
|
||||
c->sentlen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return C_OK;
|
||||
}
|
||||
@ -3304,8 +3304,8 @@ NULL
|
||||
isPauseClientAll = 0;
|
||||
} else if (strcasecmp(c->argv[3]->ptr,"all")) {
|
||||
addReplyError(c,
|
||||
"CLIENT PAUSE mode must be WRITE or ALL");
|
||||
return;
|
||||
"CLIENT PAUSE mode must be WRITE or ALL");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3492,7 +3492,7 @@ NULL
|
||||
numflags++;
|
||||
if (c->flags & CLIENT_TRACKING_CACHING) {
|
||||
addReplyBulkCString(c,"caching-yes");
|
||||
numflags++;
|
||||
numflags++;
|
||||
}
|
||||
}
|
||||
if (c->flags & CLIENT_TRACKING_OPTOUT) {
|
||||
@ -3500,7 +3500,7 @@ NULL
|
||||
numflags++;
|
||||
if (c->flags & CLIENT_TRACKING_CACHING) {
|
||||
addReplyBulkCString(c,"caching-no");
|
||||
numflags++;
|
||||
numflags++;
|
||||
}
|
||||
}
|
||||
if (c->flags & CLIENT_TRACKING_NOLOOP) {
|
||||
@ -3796,7 +3796,7 @@ size_t getClientOutputBufferMemoryUsage(client *c) {
|
||||
repl_node_num = last->id - cur->id + 1;
|
||||
}
|
||||
return repl_buf_size + (repl_node_size*repl_node_num);
|
||||
} else {
|
||||
} else {
|
||||
size_t list_item_size = sizeof(listNode) + sizeof(clientReplyBlock);
|
||||
return c->reply_bytes + (list_item_size*listLength(c->reply));
|
||||
}
|
||||
@ -4050,7 +4050,7 @@ static void pauseClientsByClient(mstime_t endTime, int isPauseClientAll) {
|
||||
if (p->paused_actions & PAUSE_ACTION_CLIENT_ALL)
|
||||
actions = PAUSE_ACTIONS_CLIENT_ALL_SET;
|
||||
}
|
||||
|
||||
|
||||
pauseActions(PAUSE_BY_CLIENT_COMMAND, endTime, actions);
|
||||
}
|
||||
|
||||
@ -4060,7 +4060,7 @@ static void pauseClientsByClient(mstime_t endTime, int isPauseClientAll) {
|
||||
* A main use case of this function is to allow pausing replication traffic
|
||||
* so that a failover without data loss to occur. Replicas will continue to receive
|
||||
* traffic to facilitate this functionality.
|
||||
*
|
||||
*
|
||||
* This function is also internally used by Redict Cluster for the manual
|
||||
* failover procedure implemented by CLUSTER FAILOVER.
|
||||
*
|
||||
|
@ -136,7 +136,7 @@ typedef struct raxStack {
|
||||
* This callback is used to perform very low level analysis of the radix tree
|
||||
* structure, scanning each possible node (but the root node), or in order to
|
||||
* reallocate the nodes to reduce the allocation fragmentation (this is the
|
||||
* Redis application for this callback).
|
||||
* Redict application for this callback).
|
||||
*
|
||||
* This is currently only supported in forward iterations (raxNext) */
|
||||
typedef int (*raxNodeCallback)(raxNode **noderef);
|
||||
|
@ -374,7 +374,7 @@ err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* RDB check main: called form server.c when Redis is executed with the
|
||||
/* RDB check main: called form server.c when Redict is executed with the
|
||||
* redict-check-rdb alias, on during RDB loading errors.
|
||||
*
|
||||
* The function works in two ways: can be called with argc/argv as a
|
||||
@ -404,7 +404,7 @@ int redict_check_rdb_main(int argc, char **argv, FILE *fp) {
|
||||
|
||||
/* In order to call the loading functions we need to create the shared
|
||||
* integer objects, however since this function may be called from
|
||||
* an already initialized Redis instance, check if we really need to. */
|
||||
* an already initialized Redict instance, check if we really need to. */
|
||||
if (shared.integers[0] == NULL)
|
||||
createSharedObjects();
|
||||
server.loading_process_events_interval_bytes = 0;
|
||||
|
@ -46,7 +46,7 @@ typedef long long ustime_t;
|
||||
/* API versions. */
|
||||
#define REDICTMODULE_APIVER_1 1
|
||||
|
||||
/* Version of the RedictModuleTypeMethods structure. Once the RedictModuleTypeMethods
|
||||
/* Version of the RedictModuleTypeMethods structure. Once the RedictModuleTypeMethods
|
||||
* structure is changed, this version number needs to be changed synchronistically. */
|
||||
#define REDICTMODULE_TYPE_METHOD_VERSION 5
|
||||
|
||||
@ -153,7 +153,7 @@ typedef struct RedictModuleStreamID {
|
||||
|
||||
/* The command is running in the context of a Lua script */
|
||||
#define REDICTMODULE_CTX_FLAGS_LUA (1<<0)
|
||||
/* The command is running inside a Redis transaction */
|
||||
/* The command is running inside a Redict transaction */
|
||||
#define REDICTMODULE_CTX_FLAGS_MULTI (1<<1)
|
||||
/* The instance is a master */
|
||||
#define REDICTMODULE_CTX_FLAGS_MASTER (1<<2)
|
||||
@ -171,13 +171,13 @@ typedef struct RedictModuleStreamID {
|
||||
#define REDICTMODULE_CTX_FLAGS_MAXMEMORY (1<<8)
|
||||
/* Maxmemory is set and has an eviction policy that may delete keys */
|
||||
#define REDICTMODULE_CTX_FLAGS_EVICT (1<<9)
|
||||
/* Redis is out of memory according to the maxmemory flag. */
|
||||
/* Redict is out of memory according to the maxmemory flag. */
|
||||
#define REDICTMODULE_CTX_FLAGS_OOM (1<<10)
|
||||
/* Less than 25% of memory available according to maxmemory. */
|
||||
#define REDICTMODULE_CTX_FLAGS_OOM_WARNING (1<<11)
|
||||
/* The command was sent over the replication link. */
|
||||
#define REDICTMODULE_CTX_FLAGS_REPLICATED (1<<12)
|
||||
/* Redis is currently loading either from AOF or RDB. */
|
||||
/* Redict is currently loading either from AOF or RDB. */
|
||||
#define REDICTMODULE_CTX_FLAGS_LOADING (1<<13)
|
||||
/* The replica has no link with its master, note that
|
||||
* there is the inverse flag as well:
|
||||
@ -197,16 +197,16 @@ typedef struct RedictModuleStreamID {
|
||||
#define REDICTMODULE_CTX_FLAGS_ACTIVE_CHILD (1<<18)
|
||||
/* The next EXEC will fail due to dirty CAS (touched keys). */
|
||||
#define REDICTMODULE_CTX_FLAGS_MULTI_DIRTY (1<<19)
|
||||
/* Redis is currently running inside background child process. */
|
||||
/* Redict is currently running inside background child process. */
|
||||
#define REDICTMODULE_CTX_FLAGS_IS_CHILD (1<<20)
|
||||
/* The current client does not allow blocking, either called from
|
||||
* within multi, lua, or from another module using RM_Call */
|
||||
#define REDICTMODULE_CTX_FLAGS_DENY_BLOCKING (1<<21)
|
||||
/* The current client uses RESP3 protocol */
|
||||
#define REDICTMODULE_CTX_FLAGS_RESP3 (1<<22)
|
||||
/* Redis is currently async loading database for diskless replication. */
|
||||
/* Redict is currently async loading database for diskless replication. */
|
||||
#define REDICTMODULE_CTX_FLAGS_ASYNC_LOADING (1<<23)
|
||||
/* Redis is starting. */
|
||||
/* Redict is starting. */
|
||||
#define REDICTMODULE_CTX_FLAGS_SERVER_STARTUP (1<<24)
|
||||
|
||||
/* Next context flag, must be updated when adding new flags above!
|
||||
@ -297,7 +297,7 @@ typedef uint64_t RedictModuleTimerID;
|
||||
/* Declare that the module can handle errors with RedictModule_SetModuleOptions. */
|
||||
#define REDICTMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0)
|
||||
|
||||
/* When set, Redis will not call RedictModule_SignalModifiedKey(), implicitly in
|
||||
/* When set, Redict will not call RedictModule_SignalModifiedKey(), implicitly in
|
||||
* RedictModule_CloseKey, and the module needs to do that when manually when keys
|
||||
* are modified from the user's perspective, to invalidate WATCH. */
|
||||
#define REDICTMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED (1<<1)
|
||||
@ -592,7 +592,7 @@ static const RedictModuleEvent
|
||||
/* Deprecated since Redis 7.0, not used anymore. */
|
||||
__attribute__ ((deprecated))
|
||||
RedictModuleEvent_ReplBackup = {
|
||||
REDICTMODULE_EVENT_REPL_BACKUP,
|
||||
REDICTMODULE_EVENT_REPL_BACKUP,
|
||||
1
|
||||
},
|
||||
RedictModuleEvent_ReplAsyncLoad = {
|
||||
@ -772,7 +772,7 @@ typedef struct RedictModuleConfigChange {
|
||||
uint64_t version; /* Not used since this structure is never passed
|
||||
from the module to the core right now. Here
|
||||
for future compatibility. */
|
||||
uint32_t num_changes; /* how many redis config options were changed */
|
||||
uint32_t num_changes; /* how many redict config options were changed */
|
||||
const char **config_names; /* the config names that were changed */
|
||||
} RedictModuleConfigChangeV1;
|
||||
|
||||
@ -1323,7 +1323,7 @@ REDICTMODULE_API int (*RedictModule_RdbSave)(RedictModuleCtx *ctx, RedictModuleR
|
||||
|
||||
#define RedictModule_IsAOFClient(id) ((id) == UINT64_MAX)
|
||||
|
||||
/* This is included inline inside each Redis module. */
|
||||
/* This is included inline inside each Redict module. */
|
||||
static int RedictModule_Init(RedictModuleCtx *ctx, const char *name, int ver, int apiver) REDICTMODULE_ATTR_UNUSED;
|
||||
static int RedictModule_Init(RedictModuleCtx *ctx, const char *name, int ver, int apiver) {
|
||||
void *getapifuncptr = ((void**)ctx)[0];
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* A RESP parser for parsing replies returned by RM_Call or Lua's
|
||||
* 'redis.call()'.
|
||||
* 'redict.call()'.
|
||||
*
|
||||
* The parser introduces callbacks that need to be set by the user. Each
|
||||
* callback represents a different reply type. Each callback gets a p_ctx that
|
||||
@ -18,7 +18,7 @@
|
||||
* - array_callback
|
||||
* - set_callback
|
||||
* - map_callback
|
||||
*
|
||||
*
|
||||
* These callbacks need to continue parsing by calling parseReply a number of
|
||||
* times, according to the supplied length. Subsequent parseReply calls may use
|
||||
* a different p_ctx, which will be used for nested CallReply objects.
|
||||
|
@ -9,10 +9,10 @@
|
||||
#define __SCRIPT_H_
|
||||
|
||||
/*
|
||||
* Script.c unit provides an API for functions and eval
|
||||
* to interact with Redis. Interaction includes mostly
|
||||
* Script.c unit provides an API for functions and eval
|
||||
* to interact with Redict. Interaction includes mostly
|
||||
* executing commands, but also functionalities like calling
|
||||
* Redis back on long scripts or check if the script was killed.
|
||||
* Redict back on long scripts or check if the script was killed.
|
||||
*
|
||||
* The interaction is done using a scriptRunCtx object that
|
||||
* need to be created by the user and initialized using scriptPrepareForRun.
|
||||
@ -22,7 +22,7 @@
|
||||
* acl, cluster, read only run, ...)
|
||||
* 2. Set Resp
|
||||
* 3. Set Replication method (AOF/REPLICATION/NONE)
|
||||
* 4. Call Redis back to on long running scripts to allow Redis reply
|
||||
* 4. Call Redict back to on long running scripts to allow Redict reply
|
||||
* to clients and perform script kill
|
||||
*/
|
||||
|
||||
|
400
src/sentinel.c
400
src/sentinel.c
File diff suppressed because it is too large
Load Diff
44
src/server.c
44
src/server.c
@ -145,7 +145,7 @@ void _serverLog(int level, const char *fmt, ...) {
|
||||
serverLogRaw(level,msg);
|
||||
}
|
||||
|
||||
/* Low level logging from signal handler. Should be used with pre-formatted strings.
|
||||
/* Low level logging from signal handler. Should be used with pre-formatted strings.
|
||||
See serverLogFromHandler. */
|
||||
void serverLogRawFromHandler(int level, const char *msg) {
|
||||
int fd;
|
||||
@ -1436,7 +1436,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
||||
* a higher frequency. */
|
||||
run_with_period(1000) {
|
||||
if ((server.aof_state == AOF_ON || server.aof_state == AOF_WAIT_REWRITE) &&
|
||||
server.aof_last_write_status == C_ERR)
|
||||
server.aof_last_write_status == C_ERR)
|
||||
{
|
||||
flushAppendOnlyFile(0);
|
||||
}
|
||||
@ -1446,8 +1446,8 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
||||
updatePausedActions();
|
||||
|
||||
/* Replication cron function -- used to reconnect to master,
|
||||
* detect transfer failures, start background RDB transfers and so forth.
|
||||
*
|
||||
* detect transfer failures, start background RDB transfers and so forth.
|
||||
*
|
||||
* If Redict is trying to failover then run the replication cron faster so
|
||||
* progress on the handshake happens more quickly. */
|
||||
if (server.failover_state != NO_FAILOVER) {
|
||||
@ -1674,7 +1674,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
||||
* processUnblockedClients(), so if there are multiple pipelined WAITs
|
||||
* and the just unblocked WAIT gets blocked again, we don't have to wait
|
||||
* a server cron cycle in absence of other event loop events. See #6623.
|
||||
*
|
||||
*
|
||||
* We also don't send the ACKs while clients are paused, since it can
|
||||
* increment the replication backlog, they'll be sent after the pause
|
||||
* if we are still the master. */
|
||||
@ -1684,7 +1684,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
||||
}
|
||||
|
||||
/* We may have received updates from clients about their current offset. NOTE:
|
||||
* this can't be done where the ACK is received since failover will disconnect
|
||||
* this can't be done where the ACK is received since failover will disconnect
|
||||
* our clients. */
|
||||
updateFailoverStatus();
|
||||
|
||||
@ -4150,12 +4150,12 @@ int processCommand(client *c) {
|
||||
|
||||
/* If the server is paused, block the client until
|
||||
* the pause has ended. Replicas are never paused. */
|
||||
if (!(c->flags & CLIENT_SLAVE) &&
|
||||
if (!(c->flags & CLIENT_SLAVE) &&
|
||||
((isPausedActions(PAUSE_ACTION_CLIENT_ALL)) ||
|
||||
((isPausedActions(PAUSE_ACTION_CLIENT_WRITE)) && is_may_replicate_command)))
|
||||
{
|
||||
blockPostponeClient(c);
|
||||
return C_OK;
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
/* Exec the command */
|
||||
@ -6843,12 +6843,12 @@ int __test_num = 0;
|
||||
/* The flags are the following:
|
||||
* --accurate: Runs tests with more iterations.
|
||||
* --large-memory: Enables tests that consume more than 100mb. */
|
||||
typedef int redisTestProc(int argc, char **argv, int flags);
|
||||
struct redisTest {
|
||||
typedef int redictTestProc(int argc, char **argv, int flags);
|
||||
struct redictTest {
|
||||
char *name;
|
||||
redisTestProc *proc;
|
||||
redictTestProc *proc;
|
||||
int failed;
|
||||
} redisTests[] = {
|
||||
} redictTests[] = {
|
||||
{"ziplist", ziplistTest},
|
||||
{"quicklist", quicklistTest},
|
||||
{"intset", intsetTest},
|
||||
@ -6863,11 +6863,11 @@ struct redisTest {
|
||||
{"listpack", listpackTest},
|
||||
{"kvstore", kvstoreTest},
|
||||
};
|
||||
redisTestProc *getTestProcByName(const char *name) {
|
||||
int numtests = sizeof(redisTests)/sizeof(struct redisTest);
|
||||
redictTestProc *getTestProcByName(const char *name) {
|
||||
int numtests = sizeof(redictTests)/sizeof(struct redictTest);
|
||||
for (int j = 0; j < numtests; j++) {
|
||||
if (!strcasecmp(name,redisTests[j].name)) {
|
||||
return redisTests[j].proc;
|
||||
if (!strcasecmp(name,redictTests[j].name)) {
|
||||
return redictTests[j].proc;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@ -6891,19 +6891,19 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[2], "all")) {
|
||||
int numtests = sizeof(redisTests)/sizeof(struct redisTest);
|
||||
int numtests = sizeof(redictTests)/sizeof(struct redictTest);
|
||||
for (j = 0; j < numtests; j++) {
|
||||
redisTests[j].failed = (redisTests[j].proc(argc,argv,flags) != 0);
|
||||
redictTests[j].failed = (redictTests[j].proc(argc,argv,flags) != 0);
|
||||
}
|
||||
|
||||
/* Report tests result */
|
||||
int failed_num = 0;
|
||||
for (j = 0; j < numtests; j++) {
|
||||
if (redisTests[j].failed) {
|
||||
if (redictTests[j].failed) {
|
||||
failed_num++;
|
||||
printf("[failed] Test - %s\n", redisTests[j].name);
|
||||
printf("[failed] Test - %s\n", redictTests[j].name);
|
||||
} else {
|
||||
printf("[ok] Test - %s\n", redisTests[j].name);
|
||||
printf("[ok] Test - %s\n", redictTests[j].name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6912,7 +6912,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
return failed_num == 0 ? 0 : 1;
|
||||
} else {
|
||||
redisTestProc *proc = getTestProcByName(argv[2]);
|
||||
redictTestProc *proc = getTestProcByName(argv[2]);
|
||||
if (!proc) return -1; /* test not found */
|
||||
return proc(argc,argv,flags);
|
||||
}
|
||||
|
26
src/server.h
26
src/server.h
@ -60,9 +60,9 @@ typedef long long ustime_t; /* microsecond time type. */
|
||||
|
||||
#define REDICTMODULE_CORE 1
|
||||
typedef struct redictObject robj;
|
||||
#include "redictmodule.h" /* Redis modules API defines. */
|
||||
#include "redictmodule.h" /* Redict modules API defines. */
|
||||
|
||||
/* Following includes allow test functions to be called from Redis main() */
|
||||
/* Following includes allow test functions to be called from Redict main() */
|
||||
#include "zipmap.h"
|
||||
#include "ziplist.h" /* Compact list data structure */
|
||||
#include "sha1.h"
|
||||
@ -264,7 +264,7 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT];
|
||||
* from the value of the key. */
|
||||
/* Other flags: */
|
||||
#define CMD_KEY_NOT_KEY (1ULL<<8) /* A 'fake' key that should be routed
|
||||
* like a key in cluster mode but is
|
||||
* like a key in cluster mode but is
|
||||
* excluded from other key checks. */
|
||||
#define CMD_KEY_INCOMPLETE (1ULL<<9) /* Means that the keyspec might not point
|
||||
* out to all keys it should cover */
|
||||
@ -653,7 +653,7 @@ typedef enum {
|
||||
#define serverAssert(_e) (likely(_e)?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),redict_unreachable()))
|
||||
#define serverPanic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),redict_unreachable()
|
||||
|
||||
/* The following macros provide assertions that are only executed during test builds and should be used to add
|
||||
/* The following macros provide assertions that are only executed during test builds and should be used to add
|
||||
* assertions that are too computationally expensive or dangerous to run during normal operations. */
|
||||
#ifdef DEBUG_ASSERTIONS
|
||||
#define debugServerAssertWithInfo(...) serverAssertWithInfo(__VA_ARGS__)
|
||||
@ -770,7 +770,7 @@ typedef struct RedictModuleType {
|
||||
char name[10]; /* 9 bytes name + null term. Charset: A-Z a-z 0-9 _- */
|
||||
} moduleType;
|
||||
|
||||
/* In Redis objects 'robj' structures of type OBJ_MODULE, the value pointer
|
||||
/* In Redict objects 'robj' structures of type OBJ_MODULE, the value pointer
|
||||
* is set to the following structure, referencing the moduleType structure
|
||||
* in order to work with the value, and at the same time providing a raw
|
||||
* pointer to the value, as created by the module commands operating with
|
||||
@ -815,7 +815,7 @@ struct RedictModule {
|
||||
};
|
||||
typedef struct RedictModule RedictModule;
|
||||
|
||||
/* This is a wrapper for the 'rio' streams used inside rdb.c in Redis, so that
|
||||
/* This is a wrapper for the 'rio' streams used inside rdb.c in Redict, so that
|
||||
* the user does not have to take the total count of the written bytes nor
|
||||
* to care about error conditions. */
|
||||
struct RedictModuleIO {
|
||||
@ -843,7 +843,7 @@ struct RedictModuleIO {
|
||||
iovar.pre_flush_buffer = NULL; \
|
||||
} while(0)
|
||||
|
||||
/* This is a structure used to export DEBUG DIGEST capabilities to Redis
|
||||
/* This is a structure used to export DEBUG DIGEST capabilities to Redict
|
||||
* modules. We want to capture both the ordered and unordered elements of
|
||||
* a data structure, so that a digest can be created in a way that correctly
|
||||
* reflects the values. See the DEBUG DIGEST command implementation for more
|
||||
@ -902,7 +902,7 @@ struct redictObject {
|
||||
* and Module types have their registered name returned. */
|
||||
char *getObjectTypeName(robj*);
|
||||
|
||||
/* Macro used to initialize a Redis object allocated on the stack.
|
||||
/* Macro used to initialize a Redict object allocated on the stack.
|
||||
* Note that this macro is taken near the structure definition to make sure
|
||||
* we'll update it when the structure is changed, to avoid bugs like
|
||||
* bug #85 introduced exactly in this way. */
|
||||
@ -1304,8 +1304,8 @@ struct sharedObjectsStruct {
|
||||
*busykeyerr, *oomerr, *plus, *messagebulk, *pmessagebulk, *subscribebulk,
|
||||
*unsubscribebulk, *psubscribebulk, *punsubscribebulk, *del, *unlink,
|
||||
*rpop, *lpop, *lpush, *rpoplpush, *lmove, *blmove, *zpopmin, *zpopmax,
|
||||
*emptyscan, *multi, *exec, *left, *right, *hset, *srem, *xgroup, *xclaim,
|
||||
*script, *replconf, *eval, *persist, *set, *pexpireat, *pexpire,
|
||||
*emptyscan, *multi, *exec, *left, *right, *hset, *srem, *xgroup, *xclaim,
|
||||
*script, *replconf, *eval, *persist, *set, *pexpireat, *pexpire,
|
||||
*time, *pxat, *absttl, *retrycount, *force, *justid, *entriesread,
|
||||
*lastid, *ping, *setid, *keepttl, *load, *createconsumer,
|
||||
*getack, *special_asterick, *special_equals, *default_username, *redacted,
|
||||
@ -1504,7 +1504,7 @@ typedef struct {
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* AIX defines hz to __hz, we don't use this define and in order to allow
|
||||
* Redis build on AIX we need to undef it. */
|
||||
* Redict build on AIX we need to undef it. */
|
||||
#ifdef _AIX
|
||||
#undef hz
|
||||
#endif
|
||||
@ -1708,7 +1708,7 @@ struct redictServer {
|
||||
long long el_cmd_cnt_max;
|
||||
/* The sum of active-expire, active-defrag and all other tasks done by cron and beforeSleep,
|
||||
but excluding read, write and AOF, which are counted by other sets of metrics. */
|
||||
monotime el_cron_duration;
|
||||
monotime el_cron_duration;
|
||||
durationStats duration_stats[EL_DURATION_TYPE_NUM];
|
||||
|
||||
/* Configuration */
|
||||
@ -3174,7 +3174,7 @@ sds keyspaceEventsFlagsToString(int flags);
|
||||
|
||||
/* Configuration */
|
||||
/* Configuration Flags */
|
||||
#define MODIFIABLE_CONFIG 0 /* This is the implied default for a standard
|
||||
#define MODIFIABLE_CONFIG 0 /* This is the implied default for a standard
|
||||
* config, which is mutable. */
|
||||
#define IMMUTABLE_CONFIG (1ULL<<0) /* Can this value only be set at startup? */
|
||||
#define SENSITIVE_CONFIG (1ULL<<1) /* Does this value contain sensitive information */
|
||||
|
14
src/tls.c
14
src/tls.c
@ -46,7 +46,7 @@ static int parseProtocolsConfig(const char *str) {
|
||||
if (!str) return REDICT_TLS_PROTO_DEFAULT;
|
||||
sds *tokens = sdssplitlen(str, strlen(str), " ", 1, &count);
|
||||
|
||||
if (!tokens) {
|
||||
if (!tokens) {
|
||||
serverLog(LL_WARNING, "Invalid tls-protocols configuration string");
|
||||
return -1;
|
||||
}
|
||||
@ -121,7 +121,7 @@ static void initCryptoLocks(void) {
|
||||
|
||||
static void tlsInit(void) {
|
||||
/* Enable configuring OpenSSL using the standard openssl.cnf
|
||||
* OPENSSL_config()/OPENSSL_init_crypto() should be the first
|
||||
* OPENSSL_config()/OPENSSL_init_crypto() should be the first
|
||||
* call to the OpenSSL* library.
|
||||
* - OPENSSL_config() should be used for OpenSSL versions < 1.1.0
|
||||
* - OPENSSL_init_crypto() should be used for OpenSSL versions >= 1.1.0
|
||||
@ -882,7 +882,7 @@ static int connTLSWritev(connection *conn_, const struct iovec *iov, int iovcnt)
|
||||
if (iov_bytes_len > NET_MAX_WRITES_PER_EVENT) break;
|
||||
}
|
||||
|
||||
/* The amount of all buffers is greater than NET_MAX_WRITES_PER_EVENT,
|
||||
/* The amount of all buffers is greater than NET_MAX_WRITES_PER_EVENT,
|
||||
* which is not worth doing so much memory copying to reduce system calls,
|
||||
* therefore, invoke connTLSWrite() multiple times to avoid memory copies. */
|
||||
if (iov_bytes_len > NET_MAX_WRITES_PER_EVENT) {
|
||||
@ -896,9 +896,9 @@ static int connTLSWritev(connection *conn_, const struct iovec *iov, int iovcnt)
|
||||
return tot_sent;
|
||||
}
|
||||
|
||||
/* The amount of all buffers is less than NET_MAX_WRITES_PER_EVENT,
|
||||
* which is worth doing more memory copies in exchange for fewer system calls,
|
||||
* so concatenate these scattered buffers into a contiguous piece of memory
|
||||
/* The amount of all buffers is less than NET_MAX_WRITES_PER_EVENT,
|
||||
* which is worth doing more memory copies in exchange for fewer system calls,
|
||||
* so concatenate these scattered buffers into a contiguous piece of memory
|
||||
* and send it away by one call to connTLSWrite(). */
|
||||
char buf[iov_bytes_len];
|
||||
size_t offset = 0;
|
||||
@ -1154,7 +1154,7 @@ int RedictModule_OnLoad(void *ctx, RedictModuleString **argv, int argc) {
|
||||
UNUSED(argc);
|
||||
|
||||
/* Connection modules must be part of the same build as redict. */
|
||||
if (strcmp(REDICT_BUILD_ID_RAW, redisBuildIdRaw())) {
|
||||
if (strcmp(REDICT_BUILD_ID_RAW, redictBuildIdRaw())) {
|
||||
serverLog(LL_NOTICE, "Connection type %s was not built together with the redict-server used.", CONN_TYPE_TLS);
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
@ -80,13 +80,13 @@ void disableTracking(client *c) {
|
||||
|
||||
static int stringCheckPrefix(unsigned char *s1, size_t s1_len, unsigned char *s2, size_t s2_len) {
|
||||
size_t min_length = s1_len < s2_len ? s1_len : s2_len;
|
||||
return memcmp(s1,s2,min_length) == 0;
|
||||
return memcmp(s1,s2,min_length) == 0;
|
||||
}
|
||||
|
||||
/* Check if any of the provided prefixes collide with one another or
|
||||
* with an existing prefix for the client. A collision is defined as two
|
||||
* prefixes that will emit an invalidation for the same key. If no prefix
|
||||
* collision is found, 1 is return, otherwise 0 is returned and the client
|
||||
* with an existing prefix for the client. A collision is defined as two
|
||||
* prefixes that will emit an invalidation for the same key. If no prefix
|
||||
* collision is found, 1 is return, otherwise 0 is returned and the client
|
||||
* has an error emitted describing the error. */
|
||||
int checkPrefixCollisionsOrReply(client *c, robj **prefixes, size_t numprefix) {
|
||||
for (size_t i = 0; i < numprefix; i++) {
|
||||
@ -97,7 +97,7 @@ int checkPrefixCollisionsOrReply(client *c, robj **prefixes, size_t numprefix) {
|
||||
raxSeek(&ri,"^",NULL,0);
|
||||
while(raxNext(&ri)) {
|
||||
if (stringCheckPrefix(ri.key,ri.key_len,
|
||||
prefixes[i]->ptr,sdslen(prefixes[i]->ptr)))
|
||||
prefixes[i]->ptr,sdslen(prefixes[i]->ptr)))
|
||||
{
|
||||
sds collision = sdsnewlen(ri.key,ri.key_len);
|
||||
addReplyErrorFormat(c,
|
||||
@ -332,7 +332,7 @@ void trackingRememberKeyToBroadcast(client *c, char *keyname, size_t keylen) {
|
||||
raxStop(&ri);
|
||||
}
|
||||
|
||||
/* This function is called from signalModifiedKey() or other places in Redis
|
||||
/* This function is called from signalModifiedKey() or other places in Redict
|
||||
* when a key changes value. In the context of keys tracking, our task here is
|
||||
* to send a notification to every client that may have keys about such caching
|
||||
* slot.
|
||||
@ -343,7 +343,7 @@ void trackingRememberKeyToBroadcast(client *c, char *keyname, size_t keylen) {
|
||||
*
|
||||
* The last argument 'bcast' tells the function if it should also schedule
|
||||
* the key for broadcasting to clients in BCAST mode. This is the case when
|
||||
* the function is called from the Redis core once a key is modified, however
|
||||
* the function is called from the Redict core once a key is modified, however
|
||||
* we also call the function in order to evict keys in the key table in case
|
||||
* of memory pressure: in that case the key didn't really change, so we want
|
||||
* just to notify the clients that are in the table for this key, that would
|
||||
@ -435,11 +435,11 @@ void trackingHandlePendingKeyInvalidations(void) {
|
||||
listEmpty(server.tracking_pending_keys);
|
||||
}
|
||||
|
||||
/* This function is called when one or all the Redis databases are
|
||||
* flushed. Caching keys are not specific for each DB but are global:
|
||||
* currently what we do is send a special notification to clients with
|
||||
* tracking enabled, sending a RESP NULL, which means, "all the keys",
|
||||
* in order to avoid flooding clients with many invalidation messages
|
||||
/* This function is called when one or all the Redict databases are
|
||||
* flushed. Caching keys are not specific for each DB but are global:
|
||||
* currently what we do is send a special notification to clients with
|
||||
* tracking enabled, sending a RESP NULL, which means, "all the keys",
|
||||
* in order to avoid flooding clients with many invalidation messages
|
||||
* for all the keys they may hold.
|
||||
*/
|
||||
void freeTrackingRadixTreeCallback(void *rt) {
|
||||
@ -481,12 +481,12 @@ void trackingInvalidateKeysOnFlush(int async) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Tracking forces Redis to remember information about which client may have
|
||||
/* Tracking forces Redict to remember information about which client may have
|
||||
* certain keys. In workloads where there are a lot of reads, but keys are
|
||||
* hardly modified, the amount of information we have to remember server side
|
||||
* could be a lot, with the number of keys being totally not bound.
|
||||
*
|
||||
* So Redis allows the user to configure a maximum number of keys for the
|
||||
* So Redict allows the user to configure a maximum number of keys for the
|
||||
* invalidation table. This function makes sure that we don't go over the
|
||||
* specified fill rate: if we are over, we can just evict information about
|
||||
* a random key, and send invalidation messages to clients like if the key was
|
||||
@ -530,7 +530,7 @@ void trackingLimitUsedSlots(void) {
|
||||
timeout_counter++;
|
||||
}
|
||||
|
||||
/* Generate Redis protocol for an array containing all the key names
|
||||
/* Generate Redict protocol for an array containing all the key names
|
||||
* in the 'keys' radix tree. If the client is not NULL, the list will not
|
||||
* include keys that were modified the last time by this client, in order
|
||||
* to implement the NOLOOP option.
|
||||
|
@ -693,7 +693,7 @@ int zmalloc_get_allocator_info(size_t *allocated, size_t *active, size_t *reside
|
||||
}
|
||||
|
||||
void set_jemalloc_bg_thread(int enable) {
|
||||
/* let jemalloc do purging asynchronously, required when there's no traffic
|
||||
/* let jemalloc do purging asynchronously, required when there's no traffic
|
||||
* after flushdb */
|
||||
char val = !!enable;
|
||||
je_mallctl("background_thread", NULL, 0, &val, 1);
|
||||
|
@ -76,8 +76,8 @@
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
/* We can enable the Redis defrag capabilities only if we are using Jemalloc
|
||||
* and the version used is our special version modified for Redis having
|
||||
/* We can enable the Redict defrag capabilities only if we are using Jemalloc
|
||||
* and the version used is our special version modified for Redict having
|
||||
* the ability to return per-allocation fragmentation hints. */
|
||||
#if defined(USE_JEMALLOC) && defined(JEMALLOC_FRAG_HINT)
|
||||
#define HAVE_DEFRAG
|
||||
|
Loading…
Reference in New Issue
Block a user