@@ -9,7 +9,7 @@ use rustls::pki_types::ServerName;
9
9
use rustls:: { ClientConnection , Connection , ServerConnection } ;
10
10
use tokio:: io:: { AsyncRead , AsyncReadExt , AsyncWrite , AsyncWriteExt , ReadBuf } ;
11
11
12
- use super :: Stream ;
12
+ use super :: { PacketProcessingMode , Stream } ;
13
13
14
14
struct Good < ' a > ( & ' a mut Connection ) ;
15
15
@@ -229,12 +229,13 @@ async fn stream_handshake() -> io::Result<()> {
229
229
{
230
230
let mut good = Good ( & mut server) ;
231
231
let mut stream = Stream :: new ( & mut good, & mut client) ;
232
- let ( r, w) = poll_fn ( |cx| stream. handshake ( cx, false ) ) . await ?;
232
+ let ( r, w) = poll_fn ( |cx| stream. handshake ( cx, PacketProcessingMode :: Sync ) ) . await ?;
233
233
234
234
assert ! ( r > 0 ) ;
235
235
assert ! ( w > 0 ) ;
236
236
237
- poll_fn ( |cx : & mut Context < ' _ > | stream. handshake ( cx, false ) ) . await ?; // finish server handshake
237
+ poll_fn ( |cx : & mut Context < ' _ > | stream. handshake ( cx, PacketProcessingMode :: Sync ) ) . await ?;
238
+ // finish server handshake
238
239
}
239
240
240
241
assert ! ( !server. is_handshaking( ) ) ;
@@ -253,12 +254,12 @@ async fn stream_buffered_handshake() -> io::Result<()> {
253
254
{
254
255
let mut good = BufWriter :: new ( Good ( & mut server) ) ;
255
256
let mut stream = Stream :: new ( & mut good, & mut client) ;
256
- let ( r, w) = poll_fn ( |cx| stream. handshake ( cx, false ) ) . await ?;
257
+ let ( r, w) = poll_fn ( |cx| stream. handshake ( cx, PacketProcessingMode :: Sync ) ) . await ?;
257
258
258
259
assert ! ( r > 0 ) ;
259
260
assert ! ( w > 0 ) ;
260
261
261
- poll_fn ( |cx| stream. handshake ( cx, false ) ) . await ?; // finish server handshake
262
+ poll_fn ( |cx| stream. handshake ( cx, PacketProcessingMode :: Sync ) ) . await ?; // finish server handshake
262
263
}
263
264
264
265
assert ! ( !server. is_handshaking( ) ) ;
@@ -275,7 +276,7 @@ async fn stream_handshake_eof() -> io::Result<()> {
275
276
let mut stream = Stream :: new ( & mut bad, & mut client) ;
276
277
277
278
let mut cx = Context :: from_waker ( noop_waker_ref ( ) ) ;
278
- let r = stream. handshake ( & mut cx, false ) ;
279
+ let r = stream. handshake ( & mut cx, PacketProcessingMode :: Sync ) ;
279
280
assert_eq ! (
280
281
r. map_err( |err| err. kind( ) ) ,
281
282
Poll :: Ready ( Err ( io:: ErrorKind :: UnexpectedEof ) )
@@ -292,7 +293,7 @@ async fn stream_handshake_write_eof() -> io::Result<()> {
292
293
let mut stream = Stream :: new ( & mut io, & mut client) ;
293
294
294
295
let mut cx = Context :: from_waker ( noop_waker_ref ( ) ) ;
295
- let r = stream. handshake ( & mut cx, false ) ;
296
+ let r = stream. handshake ( & mut cx, PacketProcessingMode :: Sync ) ;
296
297
assert_eq ! (
297
298
r. map_err( |err| err. kind( ) ) ,
298
299
Poll :: Ready ( Err ( io:: ErrorKind :: WriteZero ) )
@@ -310,7 +311,7 @@ async fn stream_handshake_regression_issues_77() -> io::Result<()> {
310
311
let mut stream = Stream :: new ( & mut bad, & mut client) ;
311
312
312
313
let mut cx = Context :: from_waker ( noop_waker_ref ( ) ) ;
313
- let r = stream. handshake ( & mut cx, false ) ;
314
+ let r = stream. handshake ( & mut cx, PacketProcessingMode :: Sync ) ;
314
315
assert_eq ! (
315
316
r. map_err( |err| err. kind( ) ) ,
316
317
Poll :: Ready ( Err ( io:: ErrorKind :: InvalidData ) )
@@ -366,31 +367,33 @@ async fn async_process_packets() -> io::Result<()> {
366
367
let mut stream = Stream :: new ( & mut good, & mut client) ;
367
368
368
369
// if feature is enabled, we expect a blocking response on process packets throughout the handshake,
369
- #[ cfg( feature = "compute-heavy-future-executor" ) ]
370
- { let result = poll_fn ( |cx| stream. handshake ( cx, true ) ) . await ;
370
+ #[ cfg( feature = "vacation" ) ]
371
+ {
372
+ let result = poll_fn ( |cx| stream. handshake ( cx, PacketProcessingMode :: Async ) ) . await ;
371
373
372
374
assert_eq ! (
373
375
result. err( ) . map( |e| e. kind( ) ) ,
374
376
Some ( io:: ErrorKind :: WouldBlock )
375
377
) ;
376
378
377
379
// finish the handshake without delegating to async session
378
- poll_fn ( |cx| stream. handshake ( cx, false ) ) . await ?; // client handshake
379
- poll_fn ( |cx : & mut Context < ' _ > | stream. handshake ( cx, true ) ) . await ?; // server handshake
380
+ poll_fn ( |cx| stream. handshake ( cx, PacketProcessingMode :: Sync ) ) . await ?; // client handshake
381
+ poll_fn ( |cx : & mut Context < ' _ > | stream. handshake ( cx, PacketProcessingMode :: Sync ) ) . await ?;
382
+ // server handshake
380
383
}
381
384
382
- // if feature is disabled, we expect normal handling
383
- #[ cfg( not( feature = "compute-heavy-future-executor " ) ) ]
385
+ // if feature is disabled, we expect normal handling even if async is passed in
386
+ #[ cfg( not( feature = "vacation " ) ) ]
384
387
{
385
388
{
386
- let ( r, w) = poll_fn ( |cx| stream. handshake ( cx, true ) ) . await ?; // client handshake
387
-
389
+ let ( r, w) = poll_fn ( |cx| stream. handshake ( cx, PacketProcessingMode :: Async ) ) . await ?; // client handshake
390
+
388
391
assert ! ( r > 0 ) ;
389
392
assert ! ( w > 0 ) ;
390
-
391
- poll_fn ( |cx| stream. handshake ( cx, true ) ) . await ?; // server handshake
393
+
394
+ poll_fn ( |cx| stream. handshake ( cx, PacketProcessingMode :: Async ) ) . await ?;
395
+ // server handshake
392
396
}
393
-
394
397
}
395
398
396
399
// once handshake is done, there is no longer blocking sending data over the stream
@@ -426,7 +429,7 @@ fn do_handshake(
426
429
let mut stream = Stream :: new ( & mut good, client) ;
427
430
428
431
while stream. session . is_handshaking ( ) {
429
- ready ! ( stream. handshake( cx, false ) ) ?;
432
+ ready ! ( stream. handshake( cx, PacketProcessingMode :: Sync ) ) ?;
430
433
}
431
434
432
435
while stream. session . wants_write ( ) {
0 commit comments