Skip to content

Commit

Permalink
Make a little bit adjustment
Browse files Browse the repository at this point in the history
Signed-off-by: hwware <[email protected]>
  • Loading branch information
hwware committed Nov 13, 2024
1 parent eb6423a commit 66129c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tests/modules/adminport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 66129c6

Please sign in to comment.