File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,17 +58,16 @@ async fn clean_up_unused_channels(
5858
5959 let mut channel_clients = state. channel_clients . lock ( ) . await ;
6060
61- let delete_namespace = if let Some ( namespace_channels) = channel_clients. get_mut ( & namespace)
62- {
63- namespace_channels. remove ( & channel_name) ;
64-
65- namespace_channels. is_empty ( )
66- } else {
67- false
68- } ;
61+ if let Some ( namespace_channels) = channel_clients. get_mut ( & namespace) {
62+ if let Some ( ( tx, _rx) ) = namespace_channels. get ( & channel_name) {
63+ if tx. sender_count ( ) <= 1 && tx. receiver_count ( ) <= 1 {
64+ namespace_channels. remove ( & channel_name) ;
65+ }
66+ }
6967
70- if delete_namespace {
71- channel_clients. remove ( & namespace) ;
68+ if namespace_channels. is_empty ( ) {
69+ channel_clients. remove ( & namespace) ;
70+ }
7271 }
7372 } ) ;
7473
@@ -441,4 +440,7 @@ mod tests {
441440
442441 assert_eq ! ( ids, vec![ "it_should_autovivify_on_publish" ] )
443442 }
443+
444+ // #[tokio::test]
445+ // async fn auto_cleanup_does_not_delete_when_multiple_connections_exist()
444446}
You can’t perform that action at this time.
0 commit comments