@@ -59,7 +59,7 @@ use tokio::sync::{
5959 broadcast:: { error:: RecvError , Receiver } ,
6060 mpsc, Mutex , RwLock ,
6161} ;
62- use tracing:: { error, info, info_span, instrument, trace, warn, Instrument as _, Span } ;
62+ use tracing:: { debug , error, info, info_span, instrument, trace, warn, Instrument as _, Span } ;
6363
6464use self :: paginator:: PaginatorError ;
6565use crate :: { client:: WeakClient , Client } ;
@@ -345,6 +345,8 @@ impl EventCache {
345345 mut rx : mpsc:: Receiver < AutoShrinkChannelPayload > ,
346346 ) {
347347 while let Some ( room_id) = rx. recv ( ) . await {
348+ trace ! ( for_room = %room_id, "received notification to shrink" ) ;
349+
348350 let room = match inner. for_room ( & room_id) . await {
349351 Ok ( room) => room,
350352 Err ( err) => {
@@ -353,6 +355,7 @@ impl EventCache {
353355 }
354356 } ;
355357
358+ trace ! ( "waiting for state lock…" ) ;
356359 let mut state = room. inner . state . write ( ) . await ;
357360
358361 match state. auto_shrink_if_no_listeners ( ) . await {
@@ -364,11 +367,16 @@ impl EventCache {
364367 //
365368 // However, better safe than sorry, and it's cheap to send an update here,
366369 // so let's do it!
367- let _ =
368- room. inner . sender . send ( RoomEventCacheUpdate :: UpdateTimelineEvents {
369- diffs,
370- origin : EventsOrigin :: Cache ,
371- } ) ;
370+ if !diffs. is_empty ( ) {
371+ let _ = room. inner . sender . send (
372+ RoomEventCacheUpdate :: UpdateTimelineEvents {
373+ diffs,
374+ origin : EventsOrigin :: Cache ,
375+ } ,
376+ ) ;
377+ }
378+ } else {
379+ debug ! ( "auto-shrinking didn't happen" ) ;
372380 }
373381 }
374382
0 commit comments