diff options
author | uriyage <78144248+uriyage@users.noreply.github.com> | 2022-11-15 00:40:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-14 14:40:35 -0800 |
commit | e4eb18b303d716aeebc4153176a6cd93b8bd5d66 (patch) | |
tree | b84cab4d7ce39dcade35dea04aaa75f019c1313a /src | |
parent | 2a2e5d416ad42eaa33088387637fc48586b45e63 (diff) | |
download | redis-e4eb18b303d716aeebc4153176a6cd93b8bd5d66.tar.gz |
Module CLIENT_CHANGE, Fix crash on free blocked client with DB!=0 (#11500)
In moduleFireServerEvent we change the real client DB to 0 on freeClient in case the event is REDISMODULE_EVENT_CLIENT_CHANGE.
It results in a crash if the client is blocked on a key on other than DB 0.
The DB change is not necessary even for module-client, as we set its DB to 0 on either createClient or moduleReleaseTempClient.
Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/module.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/src/module.c b/src/module.c index 454042668..c42536449 100644 --- a/src/module.c +++ b/src/module.c @@ -8094,7 +8094,6 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8 if (r->module_id == module_id) { RedisModuleCtx ctx; moduleCreateContext(&ctx, r->module, REDISMODULE_CTX_TEMP_CLIENT); - selectDb(ctx.client, 0); r->callback(&ctx,sender_id,type,payload,len); moduleFreeContext(&ctx); return; @@ -10907,11 +10906,6 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { RedisModuleClientInfoV1 civ1; RedisModuleReplicationInfoV1 riv1; RedisModuleModuleChangeV1 mcv1; - /* Start at DB zero by default when calling the handler. It's - * up to the specific event setup to change it when it makes - * sense. For instance for FLUSHDB events we select the correct - * DB automatically. */ - selectDb(ctx.client, 0); /* Event specific context and data pointer setup. */ if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { @@ -11396,7 +11390,6 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa } RedisModuleCtx ctx; moduleCreateContext(&ctx, NULL, REDISMODULE_CTX_TEMP_CLIENT); /* We pass NULL since we don't have a module yet. */ - selectDb(ctx.client, 0); if (onload((void*)&ctx,module_argv,module_argc) == REDISMODULE_ERR) { serverLog(LL_WARNING, "Module %s initialization failed. Module not loaded",path); |