@@ -5,7 +5,7 @@ use io_uring::types::Fd;
5
5
use io_uring:: { cqueue, opcode, squeue, types, IoUring } ;
6
6
use once_cell:: sync:: OnceCell ;
7
7
use std:: convert:: TryInto ;
8
- use std:: net:: { TcpListener , TcpStream } ;
8
+ use std:: net:: { Shutdown , TcpListener , TcpStream } ;
9
9
use std:: os:: fd:: FromRawFd ;
10
10
use std:: os:: unix:: io:: AsRawFd ;
11
11
use std:: { io, mem} ;
@@ -1120,6 +1120,7 @@ pub fn test_tcp_recv_multi<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
1120
1120
1121
1121
// write all 1024 + 256
1122
1122
send_stream. write_all ( & input) ?;
1123
+ send_stream. shutdown ( Shutdown :: Write ) ?;
1123
1124
1124
1125
// multishot recv using a buf_group with 1024 length buffers
1125
1126
let recv_e = opcode:: RecvMulti :: new ( recv_fd, 0xdead )
@@ -1146,16 +1147,16 @@ pub fn test_tcp_recv_multi<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
1146
1147
assert_eq ! ( cqes[ 1 ] . result( ) , 256 ) ; // length 256
1147
1148
assert ! ( cqueue:: more( cqes[ 1 ] . flags( ) ) ) ;
1148
1149
assert_eq ! ( cqueue:: buffer_select( cqes[ 1 ] . flags( ) ) , Some ( 1 ) ) ;
1149
- assert_eq ! ( & bufs[ 1024 ..( 1024 + 256 ) ] , & input[ 1024 ..( 1024 + 256 ) ] ) ;
1150
+ assert_eq ! ( & bufs[ 1024 ..] [ .. 256 ] , & input[ 1024 ..] [ .. 256 ] ) ;
1150
1151
1151
1152
assert_eq ! ( cqes[ 2 ] . user_data( ) , 0x22 ) ;
1152
- assert ! ( cqueue:: more( cqes[ 1 ] . flags( ) ) ) ;
1153
+ assert ! ( ! cqueue:: more( cqes[ 2 ] . flags( ) ) ) ;
1153
1154
assert_eq ! ( cqes[ 2 ] . result( ) , -105 ) ; // No buffer space available
1154
1155
1155
1156
Ok ( ( ) )
1156
1157
}
1157
1158
1158
- pub fn test_shutdown < S : squeue:: EntryMarker , C : cqueue:: EntryMarker > (
1159
+ pub fn test_tcp_shutdown < S : squeue:: EntryMarker , C : cqueue:: EntryMarker > (
1159
1160
ring : & mut IoUring < S , C > ,
1160
1161
test : & Test ,
1161
1162
) -> anyhow:: Result < ( ) > {
@@ -1165,7 +1166,7 @@ pub fn test_shutdown<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
1165
1166
test. probe. is_supported( opcode:: Shutdown :: CODE ) ;
1166
1167
) ;
1167
1168
1168
- println ! ( "test shutdown " ) ;
1169
+ println ! ( "test tcp_shutdown " ) ;
1169
1170
1170
1171
const SHUT_WR : i32 = 1 ;
1171
1172
@@ -1176,7 +1177,7 @@ pub fn test_shutdown<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
1176
1177
1177
1178
unsafe {
1178
1179
ring. submission ( )
1179
- . push ( & shutdown_e. build ( ) . into ( ) )
1180
+ . push ( & shutdown_e. build ( ) . user_data ( 0x28 ) . into ( ) )
1180
1181
. expect ( "queue is full" ) ;
1181
1182
}
1182
1183
@@ -1185,6 +1186,7 @@ pub fn test_shutdown<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
1185
1186
let cqes: Vec < cqueue:: Entry > = ring. completion ( ) . map ( Into :: into) . collect ( ) ;
1186
1187
1187
1188
assert_eq ! ( cqes. len( ) , 1 ) ;
1189
+ assert_eq ! ( cqes[ 0 ] . user_data( ) , 0x28 ) ;
1188
1190
assert_eq ! ( cqes[ 0 ] . result( ) , 0 ) ;
1189
1191
1190
1192
let text = b"C'est la vie" ;
0 commit comments