@ -214,8 +214,6 @@ impl GroupHandle {
}
}
' rx : loop {
' rx : loop {
// TODO add timeout to catch lock-ups!
if next_save < Instant ::now ( ) {
if next_save < Instant ::now ( ) {
grp_trace ! ( self , "Save time elapsed, saving if needed" ) ;
grp_trace ! ( self , "Save time elapsed, saving if needed" ) ;
self . save_if_needed ( ) . await . log_error ( "Failed to save group" ) ;
self . save_if_needed ( ) . await . log_error ( "Failed to save group" ) ;
@ -234,13 +232,13 @@ impl GroupHandle {
break 'rx ;
break 'rx ;
}
}
grp_trace ! ( self , "Waiting for message" ) ;
let timeout = next_save
let timeout = next_save
. saturating_duration_since ( Instant ::now ( ) )
. saturating_duration_since ( Instant ::now ( ) )
. min ( remains_to_idle_close )
. min ( remains_to_idle_close )
. min ( remains_to_retire )
. min ( remains_to_retire )
. max ( Duration ::from_secs ( 1 ) ) ; // at least 1s
. max ( Duration ::from_secs ( 1 ) ) ; // at least 1s
grp_debug ! ( self , "Wait for message {:?}" , timeout ) ;
match tokio ::time ::timeout ( timeout , events . next ( ) ) . await {
match tokio ::time ::timeout ( timeout , events . next ( ) ) . await {
Ok ( Some ( event ) ) = > {
Ok ( Some ( event ) ) = > {
last_rx = Instant ::now ( ) ;
last_rx = Instant ::now ( ) ;
@ -265,18 +263,6 @@ impl GroupHandle {
// Timeout so we can save if needed
// Timeout so we can save if needed
}
}
}
}
/* ping is nice, but pleroma still sometimes doesnt send
notifs after a while , just let it expire * /
// if last_ping.elapsed() > PING_INTERVAL {
// last_ping = Instant::now();
// grp_trace!(self, "Pinging");
// if events.send_ping()
// .await.is_err() {
// break 'rx;
// }
// }
}
}
grp_warn ! ( self , "Notif stream closed, will reopen" ) ;
grp_warn ! ( self , "Notif stream closed, will reopen" ) ;