Skip to content

Commit e791067

Browse files
author
Meir Shpilraien (Spielrein)
authored
Force post notification job callback to static lifetime (#357)
Post notification job callback is kept by Redis for unknown time and so we must force it live for the static lifetime. Notice that this does not mean that the value must live forever, it just means that it can not hold any none static references. For more information: https://practice.rs/lifetime/static.html#t-static
1 parent 96f814b commit e791067

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/context/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,10 @@ impl Context {
796796
/// as a logical bug that need to be fixed in the module, an attempt to protect against
797797
/// infinite loops by halting the execution could result in violation of the feature correctness
798798
/// and so Redis will make no attempt to protect the module from infinite loops.
799-
pub fn add_post_notification_job<F: FnOnce(&Context)>(&self, callback: F) -> Status {
799+
pub fn add_post_notification_job<F: FnOnce(&Context) + 'static>(
800+
&self,
801+
callback: F,
802+
) -> Status {
800803
let callback = Box::into_raw(Box::new(Some(callback)));
801804
unsafe {
802805
RedisModule_AddPostNotificationJob(

0 commit comments

Comments
 (0)