MT#55283 safeguard against incorrect usage

If keyspace notifications are not configured at all, bail with an error
when there is an attempt to add a new keyspace or remove one. We get a
segfault otherwise.

Closes #1902

Change-Id: Ie47cf5f7762792aabe38476739f0dcf9927787ce
pull/1907/head
Richard Fuchs 1 year ago
parent c07ab48457
commit 6dbf098bc7

@ -1150,6 +1150,11 @@ static void cli_incoming_ksadd(str *instr, struct cli_writer *cw, const cli_hand
unsigned long uint_keyspace_db; unsigned long uint_keyspace_db;
char *endptr; char *endptr;
if (!rtpe_redis_notify) {
cw->cw_printf(cw, "Keyspace notification feature has not been configured.\n");
return;
}
if (instr->len == 0) { if (instr->len == 0) {
cw->cw_printf(cw, "More parameters required.\n"); cw->cw_printf(cw, "More parameters required.\n");
return; return;
@ -1180,6 +1185,11 @@ static void cli_incoming_ksrm(str *instr, struct cli_writer *cw, const cli_handl
unsigned long uint_keyspace_db; unsigned long uint_keyspace_db;
char *endptr; char *endptr;
if (!rtpe_redis_notify) {
cw->cw_printf(cw, "Keyspace notification feature has not been configured.\n");
return;
}
if (instr->len == 0) { if (instr->len == 0) {
cw->cw_printf(cw, "More parameters required.\n"); cw->cw_printf(cw, "More parameters required.\n");
return; return;
@ -1214,6 +1224,11 @@ static void cli_incoming_ksrm(str *instr, struct cli_writer *cw, const cli_handl
static void cli_incoming_kslist(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { static void cli_incoming_kslist(str *instr, struct cli_writer *cw, const cli_handler_t *handler) {
GList *l; GList *l;
if (!rtpe_redis_notify) {
cw->cw_printf(cw, "Keyspace notification feature has not been configured.\n");
return;
}
cw->cw_printf(cw, "\nSubscribed-on keyspaces:\n"); cw->cw_printf(cw, "\nSubscribed-on keyspaces:\n");
rwlock_lock_r(&rtpe_config.keyspaces_lock); rwlock_lock_r(&rtpe_config.keyspaces_lock);

Loading…
Cancel
Save