diff options
author | antirez <antirez@gmail.com> | 2020-04-17 16:31:38 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2020-04-17 16:31:38 +0200 |
commit | 211e985e9ac0c10a4a182a3fdee69185174fc024 (patch) | |
tree | 10fee0e4a4615ac5782a4f72ebe4e04fd9585478 | |
parent | 7cb97aa6a431a641f871a4fe8a7a98f92c20bf4e (diff) | |
download | redis-211e985e9ac0c10a4a182a3fdee69185174fc024.tar.gz |
alsoPropagate(): just propagate() when out of context.
-rw-r--r-- | src/server.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/server.c b/src/server.c index e02b1b93e..80270af4d 100644 --- a/src/server.c +++ b/src/server.c @@ -3110,7 +3110,10 @@ void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, * The function does not take a reference to the passed 'argv' vector, * so it is up to the caller to release the passed argv (but it is usually * stack allocated). The function autoamtically increments ref count of - * passed objects, so the caller does not need to. */ + * passed objects, so the caller does not need to. + * + * Note that if we are outside the execution of a command, that is we + * are not inside call(), this function will just act like propagate(). */ void alsoPropagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, int target) { @@ -3119,6 +3122,13 @@ void alsoPropagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, if (server.loading) return; /* No propagation during loading. */ + /* Just call propagate() if we are out of the scope of a command. + * For asynchronous operations usually we want to propagate immediately. */ + if (server.current_client == NULL) { + propagate(cmd,dbid,argv,argc,target); + return; + } + argvcopy = zmalloc(sizeof(robj*)*argc); for (j = 0; j < argc; j++) { argvcopy[j] = argv[j]; |