File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2180,6 +2180,15 @@ mod sync_tests {
2180
2180
assert ! ( rx. recv( ) . is_err( ) ) ;
2181
2181
}
2182
2182
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
+
2183
2192
#[ test]
2184
2193
fn oneshot_single_thread_peek_data ( ) {
2185
2194
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> {
309
309
let mut guard = self . lock . lock ( ) . unwrap ( ) ;
310
310
311
311
// Easy cases first
312
- if guard. disconnected { return Err ( Disconnected ) }
312
+ if guard. disconnected && guard . buf . size ( ) == 0 { return Err ( Disconnected ) }
313
313
if guard. buf . size ( ) == 0 { return Err ( Empty ) }
314
314
315
315
// Be sure to wake up neighbors
You can’t perform that action at this time.
0 commit comments