@@ -1261,64 +1261,44 @@ pub fn test_tcp_recv_bundle<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
1261
1261
send_stream. write_all ( & input) ?;
1262
1262
send_stream. shutdown ( Shutdown :: Write ) ?;
1263
1263
1264
- let recv_e = opcode:: RecvBundle :: new ( recv_fd, 0xdeff )
1265
- . build ( )
1266
- . user_data ( 0x30 )
1267
- . into ( ) ;
1268
-
1269
- unsafe {
1270
- ring. submission ( ) . push ( & recv_e) . expect ( "queue is full" ) ;
1271
- }
1272
-
1273
- ring. submit_and_wait ( 1 ) ?;
1274
-
1275
- let mut cqe: cqueue:: Entry = ring. completion ( ) . next ( ) . expect ( "cqueue is empty" ) . into ( ) ;
1276
-
1277
- assert_eq ! ( cqe. user_data( ) , 0x30 ) ;
1278
- assert ! ( cqueue:: buffer_select( cqe. flags( ) ) . is_some( ) ) ;
1279
- let mut remaining = cqe. result ( ) as usize ;
1280
- let bufs = buf_ring
1281
- . rc
1282
- . get_bufs ( & buf_ring, remaining as u32 , cqe. flags ( ) ) ;
1283
- let mut section;
1284
1264
let mut input = input. as_slice ( ) ;
1285
- for buf in & bufs {
1286
- // In case of bundled recv first bundle may not be full
1287
- let to_check = std:: cmp:: min ( 256 , remaining) ;
1288
- ( section, input) = input. split_at ( to_check) ;
1289
- assert_eq ! ( buf. as_slice( ) , section) ;
1290
- remaining -= to_check;
1291
- }
1292
- assert_eq ! ( remaining, 0 ) ;
1293
1265
1294
- // Linux kernel 6.10 packs a single buffer into first recv and remaining buffers into second recv
1295
- // This behavior may change in the future
1296
- if !input. is_empty ( ) {
1297
- assert ! ( cqueue:: sock_nonempty( cqe. flags( ) ) ) ;
1266
+ // Multiple receive operations might be needed to receive everything.
1267
+ loop {
1268
+ let recv_e = opcode:: RecvBundle :: new ( recv_fd, 0xdeff )
1269
+ . build ( )
1270
+ . user_data ( 0x30 )
1271
+ . into ( ) ;
1298
1272
1299
1273
unsafe {
1300
1274
ring. submission ( ) . push ( & recv_e) . expect ( "queue is full" ) ;
1301
1275
}
1302
1276
1303
1277
ring. submit_and_wait ( 1 ) ?;
1304
1278
1305
- cqe = ring. completion ( ) . next ( ) . expect ( "cqueue is empty" ) . into ( ) ;
1279
+ let cqe: cqueue :: Entry = ring. completion ( ) . next ( ) . expect ( "cqueue is empty" ) . into ( ) ;
1306
1280
1307
1281
assert_eq ! ( cqe. user_data( ) , 0x30 ) ;
1308
1282
assert ! ( cqueue:: buffer_select( cqe. flags( ) ) . is_some( ) ) ;
1309
- remaining = cqe. result ( ) as usize ;
1310
- let second_bufs = buf_ring
1283
+ let mut remaining = cqe. result ( ) as usize ;
1284
+ let bufs = buf_ring
1311
1285
. rc
1312
1286
. get_bufs ( & buf_ring, remaining as u32 , cqe. flags ( ) ) ;
1313
- for buf in & second_bufs {
1287
+ let mut section;
1288
+ for buf in & bufs {
1314
1289
let to_check = std:: cmp:: min ( 256 , remaining) ;
1315
1290
( section, input) = input. split_at ( to_check) ;
1316
1291
assert_eq ! ( buf. as_slice( ) , section) ;
1317
1292
remaining -= to_check;
1318
1293
}
1319
1294
assert_eq ! ( remaining, 0 ) ;
1295
+
1296
+ if input. is_empty ( ) {
1297
+ break ;
1298
+ }
1299
+
1300
+ assert ! ( cqueue:: sock_nonempty( cqe. flags( ) ) ) ;
1320
1301
}
1321
- assert ! ( input. is_empty( ) ) ;
1322
1302
1323
1303
buf_ring. rc . unregister ( ring) ?;
1324
1304
0 commit comments