File tree Expand file tree Collapse file tree
crates/durability/src/imp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,13 +330,21 @@ impl<T: Send + Sync + 'static> Durability for Local<T> {
330330 type TxData = Txdata < T > ;
331331
332332 fn append_tx ( & self , tx : Transaction < Self :: TxData > ) {
333- let send = || self . queue . blocking_send ( tx) ;
334- if tokio:: runtime:: Handle :: try_current ( ) . is_ok ( ) {
335- tokio:: task:: block_in_place ( send)
336- } else {
337- send ( )
333+ match self . queue . try_reserve ( ) {
334+ Ok ( permit) => permit. send ( tx) ,
335+ Err ( mpsc:: error:: TrySendError :: Closed ( _) ) => {
336+ panic ! ( "durability actor crashed" ) ;
337+ }
338+ Err ( mpsc:: error:: TrySendError :: Full ( _) ) => {
339+ let send = || self . queue . blocking_send ( tx) ;
340+ if tokio:: runtime:: Handle :: try_current ( ) . is_ok ( ) {
341+ tokio:: task:: block_in_place ( send)
342+ } else {
343+ send ( )
344+ }
345+ . expect ( "durability actor crashed" ) ;
346+ }
338347 }
339- . expect ( "durability actor crashed" ) ;
340348
341349 self . queue_depth . fetch_add ( 1 , Relaxed ) ;
342350 }
You can’t perform that action at this time.
0 commit comments