File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2180,6 +2180,15 @@ mod sync_tests {
21802180 assert ! ( rx. recv( ) . is_err( ) ) ;
21812181 }
21822182
2183+ #[ test]
2184+ fn oneshot_single_thread_try_recv_closed_with_data ( ) {
2185+ let ( tx, rx) = sync_channel :: < i32 > ( 1 ) ;
2186+ tx. send ( 10 ) . unwrap ( ) ;
2187+ drop ( tx) ;
2188+ assert_eq ! ( rx. try_recv( ) , Ok ( 10 ) ) ;
2189+ assert_eq ! ( rx. try_recv( ) , Err ( TryRecvError :: Disconnected ) ) ;
2190+ }
2191+
21832192 #[ test]
21842193 fn oneshot_single_thread_peek_data ( ) {
21852194 let ( tx, rx) = sync_channel :: < i32 > ( 1 ) ;
Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ impl<T> Packet<T> {
309309 let mut guard = self . lock . lock ( ) . unwrap ( ) ;
310310
311311 // Easy cases first
312- if guard. disconnected { return Err ( Disconnected ) }
312+ if guard. disconnected && guard . buf . size ( ) == 0 { return Err ( Disconnected ) }
313313 if guard. buf . size ( ) == 0 { return Err ( Empty ) }
314314
315315 // Be sure to wake up neighbors
You can’t perform that action at this time.
0 commit comments