Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
6ea8641a
Commit
6ea8641a
authored
Oct 16, 2019
by
antirez
Browse files
Modules: add the client ID to the client info structure.
parent
d2d74ca0
Changes
1
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
6ea8641a
...
@@ -1559,10 +1559,16 @@ unsigned long long RM_GetClientId(RedisModuleCtx *ctx) {
...
@@ -1559,10 +1559,16 @@ unsigned long long RM_GetClientId(RedisModuleCtx *ctx) {
* with the following fields:
* with the following fields:
*
*
* uint64_t flags; // REDISMODULE_CLIENTINFO_FLAG_*
* uint64_t flags; // REDISMODULE_CLIENTINFO_FLAG_*
* uint64_t id; // Client ID
* char addr[46]; // IPv4 or IPv6 address.
* char addr[46]; // IPv4 or IPv6 address.
* uint16_t port; // TCP port.
* uint16_t port; // TCP port.
* uint16_t db; // Selected DB.
* uint16_t db; // Selected DB.
*
*
* Note: the client ID is useless in the context of this call, since we
* already know, however the same structure could be used in other
* contexts where we don't know the client ID, yet the same structure
* is returned.
*
* With flags having the following meaning:
* With flags having the following meaning:
*
*
* REDISMODULE_CLIENTINFO_FLAG_SSL Client using SSL connection.
* REDISMODULE_CLIENTINFO_FLAG_SSL Client using SSL connection.
...
@@ -1588,6 +1594,7 @@ int RM_GetClientInfoById(void *ci, uint64_t id) {
...
@@ -1588,6 +1594,7 @@ int RM_GetClientInfoById(void *ci, uint64_t id) {
struct {
struct {
uint64_t version; /* Version of this structure for ABI compat. */
uint64_t version; /* Version of this structure for ABI compat. */
uint64_t flags; /* REDISMODULE_CLIENTINFO_FLAG_* */
uint64_t flags; /* REDISMODULE_CLIENTINFO_FLAG_* */
uint64_t id; /* Client ID. */
char addr[46]; /* IPv4 or IPv6 address. */
char addr[46]; /* IPv4 or IPv6 address. */
uint16_t port; /* TCP port. */
uint16_t port; /* TCP port. */
uint16_t db; /* Selected DB. */
uint16_t db; /* Selected DB. */
...
@@ -1618,6 +1625,7 @@ int RM_GetClientInfoById(void *ci, uint64_t id) {
...
@@ -1618,6 +1625,7 @@ int RM_GetClientInfoById(void *ci, uint64_t id) {
anetPeerToString(client->fd,ci1->addr,sizeof(ci1->addr),&port);
anetPeerToString(client->fd,ci1->addr,sizeof(ci1->addr),&port);
ci1->port = port;
ci1->port = port;
ci1->db = client->db->id;
ci1->db = client->db->id;
ci1->id = client->id;
return REDISMODULE_OK;
return REDISMODULE_OK;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment