@@ -1750,7 +1750,7 @@ pub fn test_udp_recvmsg_multishot<S: squeue::EntryMarker, C: cqueue::EntryMarker
1750
1750
// Each one is 512 bytes large.
1751
1751
const BUF_GROUP : u16 = 33 ;
1752
1752
const SIZE : usize = 512 ;
1753
- let mut buffers = [ [ 0u8 ; SIZE ] ; 3 ] ;
1753
+ let mut buffers = [ [ 0u8 ; SIZE ] ; 2 ] ;
1754
1754
for ( index, buf) in buffers. iter_mut ( ) . enumerate ( ) {
1755
1755
let provide_bufs_e = io_uring:: opcode:: ProvideBuffers :: new (
1756
1756
buf. as_mut_ptr ( ) ,
@@ -1828,9 +1828,9 @@ pub fn test_udp_recvmsg_multishot<S: squeue::EntryMarker, C: cqueue::EntryMarker
1828
1828
1829
1829
// Check the completion events for the two UDP messages, plus a trailing
1830
1830
// CQE signaling that we ran out of buffers.
1831
- ring. submitter ( ) . submit_and_wait ( 5 ) . unwrap ( ) ;
1831
+ ring. submitter ( ) . submit_and_wait ( 6 ) . unwrap ( ) ;
1832
1832
let cqes: Vec < io_uring:: cqueue:: Entry > = ring. completion ( ) . map ( Into :: into) . collect ( ) ;
1833
- assert_eq ! ( cqes. len( ) , 5 ) ;
1833
+ assert_eq ! ( cqes. len( ) , 6 ) ;
1834
1834
for cqe in cqes {
1835
1835
let is_more = io_uring:: cqueue:: more ( cqe. flags ( ) ) ;
1836
1836
match cqe. user_data ( ) {
@@ -1848,9 +1848,8 @@ pub fn test_udp_recvmsg_multishot<S: squeue::EntryMarker, C: cqueue::EntryMarker
1848
1848
}
1849
1849
}
1850
1850
// RecvMsgMulti
1851
- 77 => {
1852
- assert ! ( cqe. result( ) > 0 ) ;
1853
- assert ! ( is_more) ;
1851
+ 77 if is_more => {
1852
+ assert ! ( cqe. result( ) > 0 , "{:?}" , cqe. result( ) ) ;
1854
1853
let buf_id = io_uring:: cqueue:: buffer_select ( cqe. flags ( ) ) . unwrap ( ) ;
1855
1854
let tmp_buf = & buffers[ buf_id as usize ] ;
1856
1855
let msg = types:: RecvMsgOut :: parse ( tmp_buf, & msghdr) . unwrap ( ) ;
@@ -1872,6 +1871,10 @@ pub fn test_udp_recvmsg_multishot<S: squeue::EntryMarker, C: cqueue::EntryMarker
1872
1871
assert_eq ! ( addr. ip( ) , client_addr. ip( ) ) ;
1873
1872
assert_eq ! ( addr. port( ) , client_addr. port( ) ) ;
1874
1873
}
1874
+ // RecvMsgMulti
1875
+ 77 => {
1876
+ assert_eq ! ( cqe. result( ) , -105 ) ;
1877
+ }
1875
1878
_ => {
1876
1879
unreachable ! ( )
1877
1880
}
@@ -2262,11 +2265,12 @@ pub fn test_tcp_recvzc<S: squeue::EntryMarker>(test: &Test) -> anyhow::Result<()
2262
2265
test. probe. is_supported( opcode:: RecvZc :: CODE ) ;
2263
2266
) ;
2264
2267
2265
- use :: anyhow:: anyhow;
2266
- use :: core:: sync:: atomic:: { self , AtomicU32 } ;
2267
- use :: std:: convert:: TryFrom ;
2268
+ use anyhow:: anyhow;
2269
+ use std:: convert:: TryFrom ;
2270
+ use std:: ptr:: { self , NonNull } ;
2271
+ use std:: sync:: atomic:: { self , AtomicU32 } ;
2268
2272
2269
- #[ allow( missing_docs ) ]
2273
+ #[ allow( non_camel_case_types ) ]
2270
2274
#[ repr( C ) ]
2271
2275
#[ derive( Debug , Copy , Clone , Default ) ]
2272
2276
#[ non_exhaustive]
@@ -2304,41 +2308,41 @@ pub fn test_tcp_recvzc<S: squeue::EntryMarker>(test: &Test) -> anyhow::Result<()
2304
2308
. build ( 8 ) ?;
2305
2309
2306
2310
// Create socket.
2307
- let socket = :: std:: net:: TcpListener :: bind ( "127.0.0.1:9999" ) ?;
2308
- let if_idx = unsafe { :: libc:: if_nametoindex ( if_name. as_ptr ( ) ) } ;
2311
+ let socket = std:: net:: TcpListener :: bind ( "127.0.0.1:9999" ) ?;
2312
+ let if_idx = unsafe { libc:: if_nametoindex ( if_name. as_ptr ( ) ) } ;
2309
2313
2310
2314
let rq_entries = 4096u32 ;
2311
- let page_size = usize:: try_from ( unsafe { :: libc:: sysconf ( :: libc:: _SC_PAGESIZE) } ) ?;
2315
+ let page_size = usize:: try_from ( unsafe { libc:: sysconf ( libc:: _SC_PAGESIZE) } ) ?;
2312
2316
2313
2317
// Create area pointer.
2314
2318
let area_size = 8192 * page_size;
2315
2319
let area_ptr = unsafe {
2316
- :: libc:: mmap (
2317
- :: core :: ptr:: null_mut ( ) ,
2320
+ libc:: mmap (
2321
+ ptr:: null_mut ( ) ,
2318
2322
area_size,
2319
- :: libc:: PROT_READ | :: libc:: PROT_WRITE ,
2320
- :: libc:: MAP_PRIVATE | :: libc:: MAP_ANONYMOUS ,
2323
+ libc:: PROT_READ | libc:: PROT_WRITE ,
2324
+ libc:: MAP_PRIVATE | libc:: MAP_ANONYMOUS ,
2321
2325
0 ,
2322
2326
0 ,
2323
2327
)
2324
2328
} ;
2325
- let area_ptr = :: core :: ptr :: NonNull :: new ( area_ptr) . ok_or_else ( || anyhow ! ( "null pointer" ) ) ?;
2329
+ let area_ptr = NonNull :: new ( area_ptr) . ok_or_else ( || anyhow ! ( "null pointer" ) ) ?;
2326
2330
2327
2331
// Create ring pointer.
2328
2332
let mut ring_size = usize:: try_from ( rq_entries) ? * size_of :: < types:: io_uring_zcrx_rqe > ( ) ;
2329
2333
ring_size += page_size;
2330
2334
ring_size = ( ring_size + page_size - 1 ) & !( page_size - 1 ) ;
2331
2335
let ring_ptr = unsafe {
2332
- :: libc:: mmap (
2333
- :: core :: ptr:: null_mut ( ) ,
2336
+ libc:: mmap (
2337
+ ptr:: null_mut ( ) ,
2334
2338
area_size,
2335
- :: libc:: PROT_READ | :: libc:: PROT_WRITE ,
2336
- :: libc:: MAP_PRIVATE | :: libc:: MAP_ANONYMOUS ,
2339
+ libc:: PROT_READ | libc:: PROT_WRITE ,
2340
+ libc:: MAP_PRIVATE | libc:: MAP_ANONYMOUS ,
2337
2341
0 ,
2338
2342
0 ,
2339
2343
)
2340
2344
} ;
2341
- let ring_ptr = :: core :: ptr :: NonNull :: new ( ring_ptr) . ok_or_else ( || anyhow ! ( "null pointer" ) ) ?;
2345
+ let ring_ptr = NonNull :: new ( ring_ptr) . ok_or_else ( || anyhow ! ( "null pointer" ) ) ?;
2342
2346
2343
2347
// Create region desc.
2344
2348
let mut region_reg = types:: io_uring_region_desc:: default ( ) ;
@@ -2356,8 +2360,8 @@ pub fn test_tcp_recvzc<S: squeue::EntryMarker>(test: &Test) -> anyhow::Result<()
2356
2360
reg. if_idx = if_idx;
2357
2361
reg. if_rxq = if_rxq;
2358
2362
reg. rq_entries = rq_entries;
2359
- reg. area_ptr = :: core :: ptr:: from_mut ( & mut area_reg) . addr ( ) . try_into ( ) ?;
2360
- reg. region_ptr = :: core :: ptr:: from_mut ( & mut region_reg) . addr ( ) . try_into ( ) ?;
2363
+ reg. area_ptr = ptr:: from_mut ( & mut area_reg) . addr ( ) . try_into ( ) ?;
2364
+ reg. region_ptr = ptr:: from_mut ( & mut region_reg) . addr ( ) . try_into ( ) ?;
2361
2365
2362
2366
// Register ifq.
2363
2367
ring. submitter ( ) . register_ifq ( & reg) ?;
@@ -2382,8 +2386,8 @@ pub fn test_tcp_recvzc<S: squeue::EntryMarker>(test: &Test) -> anyhow::Result<()
2382
2386
// Submit the accept op.
2383
2387
let sqe = opcode:: Accept :: new (
2384
2388
types:: Fd ( socket. as_raw_fd ( ) ) ,
2385
- :: core :: ptr:: null_mut ( ) ,
2386
- :: core :: ptr:: null_mut ( ) ,
2389
+ ptr:: null_mut ( ) ,
2390
+ ptr:: null_mut ( ) ,
2387
2391
)
2388
2392
. build ( )
2389
2393
. user_data ( REQ_TYPE_ACCEPT )
@@ -2392,24 +2396,24 @@ pub fn test_tcp_recvzc<S: squeue::EntryMarker>(test: &Test) -> anyhow::Result<()
2392
2396
2393
2397
// Spawn the send thread.
2394
2398
let conn = :: std:: thread:: spawn ( || loop {
2395
- if let Ok ( mut stream) = :: std:: net:: TcpStream :: connect ( "127.0.0.1:9999" ) {
2399
+ if let Ok ( mut stream) = std:: net:: TcpStream :: connect ( "127.0.0.1:9999" ) {
2396
2400
let mut buf = vec ! [ ] ;
2397
- for slice in std :: iter :: repeat_n ( DATA , 64 ) {
2398
- buf. extend ( slice ) ;
2401
+ for _ in 0 .. 64 {
2402
+ buf. extend ( DATA ) ;
2399
2403
}
2400
2404
let mut written = 0u32 ;
2401
2405
while written < STREAM_SIZE {
2402
2406
// We park here and wait for the receiver to unpark us so that
2403
2407
// we don't overwhelm the receive queue and cause the device to
2404
2408
// run out of memory.
2405
- :: std:: thread:: park ( ) ;
2409
+ std:: thread:: park ( ) ;
2406
2410
stream. write_all ( & buf) . unwrap ( ) ;
2407
2411
written += u32:: try_from ( buf. len ( ) ) . unwrap ( ) ;
2408
2412
}
2409
2413
stream. shutdown ( Shutdown :: Write ) . unwrap ( ) ;
2410
2414
break ;
2411
2415
}
2412
- :: core:: hint:: spin_loop ( ) ;
2416
+ core:: hint:: spin_loop ( ) ;
2413
2417
} ) ;
2414
2418
2415
2419
// Submit and wait for the accept cqe to process.
@@ -2453,7 +2457,7 @@ pub fn test_tcp_recvzc<S: squeue::EntryMarker>(test: &Test) -> anyhow::Result<()
2453
2457
// Get the received data.
2454
2458
let data = unsafe { area_ptr. add ( usize:: try_from ( rcqe. off & mask) ?) } ;
2455
2459
let data = unsafe {
2456
- :: core:: slice:: from_raw_parts :: < u8 > ( data. cast ( ) . as_ptr ( ) , usize:: try_from ( len) ?)
2460
+ core:: slice:: from_raw_parts :: < u8 > ( data. cast ( ) . as_ptr ( ) , usize:: try_from ( len) ?)
2457
2461
} ;
2458
2462
2459
2463
// Verify that the data matches what we expected.
0 commit comments