From 46749c14c6c39cea82980854023a4ec7dae00312 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 23 Jul 2019 11:03:04 -0700 Subject: [PATCH] test(client): fix background thread panics --- tests/client.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/client.rs b/tests/client.rs index 1e07a3c2..e924ef70 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -940,7 +940,7 @@ mod dispatch_impl { let (closes_tx, closes) = mpsc::channel(10); let (tx1, rx1) = oneshot::channel(); - let (_client_drop_tx, client_drop_rx) = oneshot::channel::<()>(); + let (_client_drop_tx, client_drop_rx) = std::sync::mpsc::channel::<()>(); thread::spawn(move || { let mut sock = server.accept().unwrap().0; @@ -954,7 +954,7 @@ mod dispatch_impl { // prevent this thread from closing until end of test, so the connection // stays open and idle until Client is dropped - Runtime::new().unwrap().block_on(client_drop_rx.into_future()).unwrap(); + let _ = client_drop_rx.recv(); }); let res = { @@ -989,7 +989,7 @@ mod dispatch_impl { let (closes_tx, closes) = mpsc::channel(10); let (tx1, rx1) = oneshot::channel(); - let (_client_drop_tx, client_drop_rx) = oneshot::channel::<()>(); + let (_client_drop_tx, client_drop_rx) = std::sync::mpsc::channel::<()>(); thread::spawn(move || { let mut sock = server.accept().unwrap().0; @@ -1002,7 +1002,7 @@ mod dispatch_impl { // prevent this thread from closing until end of test, so the connection // stays open and idle until Client is dropped - Runtime::new().unwrap().block_on(client_drop_rx.into_future()).unwrap(); + let _ = client_drop_rx.recv(); }); let res = { @@ -1039,7 +1039,7 @@ mod dispatch_impl { let (closes_tx, closes) = mpsc::channel(10); let (tx1, rx1) = oneshot::channel(); - let (_tx2, rx2) = oneshot::channel::<()>(); + let (_tx2, rx2) = std::sync::mpsc::channel::<()>(); thread::spawn(move || { let mut sock = server.accept().unwrap().0; @@ -1049,7 +1049,10 @@ mod dispatch_impl { sock.read(&mut buf).expect("read 1"); sock.write_all(b"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n").unwrap(); let _ = tx1.send(()); - let _ = Runtime::new().unwrap().block_on(rx2).unwrap(); + + // prevent this thread from closing until end of test, so the connection + // stays open and idle until Client is dropped + let _ = rx2.recv(); }); let client = Client::builder()