mirror of https://github.com/fafhrd91/actix-web
fix unused_addr
This commit is contained in:
parent
1531c7898d
commit
04b678a105
|
@ -7,7 +7,7 @@ use open_ssl::ssl::SslAcceptorBuilder;
|
|||
use actix_web::{web, App, HttpResponse, HttpServer};
|
||||
|
||||
fn unused_addr() -> net::SocketAddr {
|
||||
(1025..65535).find_map(|port| {
|
||||
match (1025..65535).find_map(|port| {
|
||||
match net::TcpListener::bind(net::SocketAddr::new(
|
||||
net::IpAddr::V4(net::Ipv4Addr::new(127, 0, 0, 1)),
|
||||
port,
|
||||
|
@ -17,8 +17,10 @@ fn unused_addr() -> net::SocketAddr {
|
|||
}
|
||||
Err(_) => None,
|
||||
}
|
||||
});
|
||||
panic!("Could not find an unused port!");
|
||||
}) {
|
||||
Some(addr) => addr.unwrap(),
|
||||
None => panic!("Could not find an unused port!")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
|
Loading…
Reference in New Issue