mirror of
https://github.com/fluencelabs/redis
synced 2025-06-21 21:11:33 +00:00
Update PR #6537: use a fresh time outside call().
One problem with the solution proposed so far in #6537 is that key lookups outside a command execution via call(), still used a cached time. The cached time needed to be refreshed in multiple places, especially because of modules callbacks from timers, cluster bus, and thread safe contexts, that may use RM_Open(). In order to avoid this problem, this commit introduces the ability to detect if we are inside call(): this way we can use the reference fixed time only when we are in the context of a command execution or Lua script, but for the asynchronous lookups, we can still use mstime() to get a fresh time reference.
This commit is contained in:
@ -2780,6 +2780,7 @@ void initServer(void) {
|
||||
server.hz = server.config_hz;
|
||||
server.pid = getpid();
|
||||
server.current_client = NULL;
|
||||
server.call_depth = 0;
|
||||
server.clients = listCreate();
|
||||
server.clients_index = raxNew();
|
||||
server.clients_to_close = listCreate();
|
||||
@ -3252,6 +3253,8 @@ void call(client *c, int flags) {
|
||||
int client_old_flags = c->flags;
|
||||
struct redisCommand *real_cmd = c->cmd;
|
||||
|
||||
server.call_depth++;
|
||||
|
||||
/* Sent the command to clients in MONITOR mode, only if the commands are
|
||||
* not generated from reading an AOF. */
|
||||
if (listLength(server.monitors) &&
|
||||
@ -3377,6 +3380,7 @@ void call(client *c, int flags) {
|
||||
trackingRememberKeys(caller);
|
||||
}
|
||||
|
||||
server.call_depth--;
|
||||
server.stat_numcommands++;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user