summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeir Shpilraien (Spielrein) <meir@redislabs.com>2020-11-09 10:46:23 +0200
committerOran Agra <oran@redislabs.com>2021-01-12 16:25:37 +0200
commitfb86ecb802c45fac54aa7087e37592a9cbc0ab14 (patch)
tree2be6d8c43f72558e33216757e4e6df9643518a3e
parent2c5865cd907527f59cca28c6e77ce52a9c607e25 (diff)
downloadredis-fb86ecb802c45fac54aa7087e37592a9cbc0ab14.tar.gz
Moved RMAPI_FUNC_SUPPORTED location such that it will be visible to modules (#8037)
The RMAPI_FUNC_SUPPORTED was defined in the wrong place on redismodule.h and was not visible to modules. (cherry picked from commit 97d647a13920c230a27685992a23679b44b73550)
-rw-r--r--src/redismodule.h4
-rw-r--r--tests/modules/fork.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/src/redismodule.h b/src/redismodule.h
index 5da7d8658..2e8bc7039 100644
--- a/src/redismodule.h
+++ b/src/redismodule.h
@@ -1018,13 +1018,13 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
#define RedisModule_Assert(_e) ((_e)?(void)0 : (RedisModule__Assert(#_e,__FILE__,__LINE__),exit(1)))
+#define RMAPI_FUNC_SUPPORTED(func) (func != NULL)
+
#else
/* Things only defined for the modules core, not exported to modules
* including this file. */
#define RedisModuleString robj
-#define RMAPI_FUNC_SUPPORTED(func) (func != NULL)
-
#endif /* REDISMODULE_CORE */
#endif /* REDISMODULE_H */
diff --git a/tests/modules/fork.c b/tests/modules/fork.c
index 0443d9ef0..50889eef9 100644
--- a/tests/modules/fork.c
+++ b/tests/modules/fork.c
@@ -28,6 +28,12 @@ int fork_create(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
RedisModule_WrongArity(ctx);
return REDISMODULE_OK;
}
+
+ if(!RMAPI_FUNC_SUPPORTED(RedisModule_Fork)){
+ RedisModule_ReplyWithError(ctx, "Fork api is not supported in the current redis version");
+ return REDISMODULE_OK;
+ }
+
RedisModule_StringToLongLong(argv[1], &code_to_exit_with);
exitted_with_code = -1;
child_pid = RedisModule_Fork(done_handler, (void*)0xdeadbeef);