From 66129c63dfbf5afae95ad48ac37bd9538256e579 Mon Sep 17 00:00:00 2001 From: hwware Date: Wed, 13 Nov 2024 15:49:01 +0000 Subject: [PATCH] Make a little bit adjustment Signed-off-by: hwware --- src/module.c | 9 +++++---- tests/modules/adminport.c | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/module.c b/src/module.c index 52c92d5164..0e4169d777 100644 --- a/src/module.c +++ b/src/module.c @@ -1054,6 +1054,11 @@ void VM_KeyAtPos(ValkeyModuleCtx *ctx, int pos) { VM_KeyAtPosWithFlags(ctx, pos, flags); } +/* Return the connected server port of current client */ +int VM_GetClientConnectedPort(ValkeyModuleCtx *ctx) { + return getClientConnectedPort(ctx->client); +} + /* Return non-zero if a module command, that was declared with the * flag "getchannels-api", is called in a special way to get the channel positions * and not to get executed. Otherwise zero is returned. */ @@ -2309,10 +2314,6 @@ int VM_IsModuleNameBusy(const char *name) { return de != NULL; } -int VM_GetClientConnectedPort(ValkeyModuleCtx *ctx) { - return getClientConnectedPort(ctx->client); -} - /* Return the current UNIX time in milliseconds. */ mstime_t VM_Milliseconds(void) { return mstime(); diff --git a/tests/modules/adminport.c b/tests/modules/adminport.c index 155013928d..edac6817b9 100644 --- a/tests/modules/adminport.c +++ b/tests/modules/adminport.c @@ -7,6 +7,7 @@ int testadminport_runspecificcommand(ValkeyModuleCtx *ctx, VALKEYMODULE_NOT_USED(argv); VALKEYMODULE_NOT_USED(argc); int port = ValkeyModule_GetClientConnectedPort(ctx); + /* Here we assume port 7001 is the admin-port */ if (port == 7001) { ValkeyModule_ReplyWithSimpleString(ctx, "You can execute this command"); } else {