Skip to content

Commit

Permalink
update deprecated crate net2 -> socket2
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Mar 9, 2021
1 parent 10a7a5a commit 036cc76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ streams = []

[dev-dependencies]
rand = "0.8"
net2 = "0.2"
socket2 = "0.3"
assert_approx_eq = "1.0"
fnv = "1.0.5"
futures = "0.3"
Expand Down
16 changes: 8 additions & 8 deletions tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::{
env, fs,
io::{self, Write},
net::SocketAddr,
path::PathBuf,
process,
thread::sleep,
Expand All @@ -11,6 +12,7 @@ use std::{

use futures::Future;
use redis::Value;
use socket2::{Domain, Socket, Type};

pub fn current_thread_runtime() -> tokio::runtime::Runtime {
let mut builder = tokio::runtime::Builder::new_current_thread();
Expand Down Expand Up @@ -78,14 +80,12 @@ impl RedisServer {
ServerType::Tcp { tls } => {
// this is technically a race but we can't do better with
// the tools that redis gives us :(
let listener = net2::TcpBuilder::new_v4()
.unwrap()
.reuse_address(true)
.unwrap()
.bind("127.0.0.1:0")
.unwrap()
.listen(1)
.unwrap();
let addr = &"127.0.0.1:0".parse::<SocketAddr>().unwrap().into();
let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap();
socket.set_reuse_address(true).unwrap();
socket.bind(addr).unwrap();
socket.listen(1).unwrap();
let listener = socket.into_tcp_listener();
let redis_port = listener.local_addr().unwrap().port();
if tls {
redis::ConnectionAddr::TcpTls {
Expand Down

0 comments on commit 036cc76

Please sign in to comment.