Skip to content

Commit e7d7b8c

Browse files
fix RED-144347, made needed change to properly run on Redis 6. (#403)
* fix RED-144347, made needed change to properly run on Redis 6. * Upgrade to rust 1.81.0
1 parent 6472bc4 commit e7d7b8c

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- [7-0, "7.2"]
1919
- [7-2, "7.2"]
2020
toolchain:
21-
- 1.78.0
21+
- 1.81.0
2222
- stable
2323

2424
steps:

src/context/commands.rs

+4
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ pub fn register_commands(ctx: &Context) -> Status {
504504
pub fn register_commands(ctx: &Context) -> Status {
505505
register_commands_internal(ctx).map_or_else(
506506
|e| {
507+
/* Make sure new command registration API is not been used. */
508+
if COMMANDS_LIST.is_empty() {
509+
return Status::Ok;
510+
}
507511
ctx.log_warning(&e.to_string());
508512
Status::Err
509513
},

src/macros.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,17 @@ macro_rules! redis_command {
4848
return $crate::raw::Status::Err as c_int;
4949
}
5050

51-
let command =
52-
unsafe { $crate::raw::RedisModule_GetCommand.unwrap()($ctx, name.as_ptr()) };
53-
if command.is_null() {
54-
$crate::raw::redis_log(
55-
$ctx,
56-
&format!("Error: failed to get command {}", $command_name),
57-
);
58-
return $crate::raw::Status::Err as c_int;
59-
}
60-
6151
let mandatory = AclCategory::from($mandatory_acl_categories);
6252
if let Some(RM_SetCommandACLCategories) = $crate::raw::RedisModule_SetCommandACLCategories {
53+
let command =
54+
unsafe { $crate::raw::RedisModule_GetCommand.unwrap()($ctx, name.as_ptr()) };
55+
if command.is_null() {
56+
$crate::raw::redis_log(
57+
$ctx,
58+
&format!("Error: failed to get command {}", $command_name),
59+
);
60+
return $crate::raw::Status::Err as c_int;
61+
}
6362
let mut optional_failed = true;
6463
let mut acl_categories = CString::default();
6564
$(
@@ -417,7 +416,9 @@ macro_rules! redis_module {
417416
register_enum_configuration(&context, $enum_configuration_name, $enum_configuration_val, default, $enum_flags_options, $enum_on_changed);
418417
)*
419418
)?
420-
raw::RedisModule_LoadConfigs.unwrap()(ctx);
419+
if let Some(load_config) = raw::RedisModule_LoadConfigs {
420+
load_config(ctx);
421+
}
421422

422423
$(
423424
$crate::redis_command!(ctx, $module_config_get_command, |ctx, args: Vec<RedisString>| {

0 commit comments

Comments
 (0)