fix: try and hold port better

This commit is contained in:
dr-frmr 2024-06-11 12:57:47 -06:00
parent 7f6fff069a
commit c367f1dfab
No known key found for this signature in database
2 changed files with 9 additions and 8 deletions

View File

@ -736,8 +736,8 @@ async fn serve_register_fe(
tx,
kill_rx,
our_ip,
ws_networking,
tcp_networking,
(ws_networking.0.as_ref(), ws_networking.1),
(tcp_networking.0.as_ref(), tcp_networking.1),
http_server_port,
disk_keyfile,
maybe_rpc) => {
@ -757,6 +757,9 @@ async fn serve_register_fe(
let _ = kill_tx.send(true);
drop(ws_networking.0);
drop(tcp_networking.0);
(our, encoded_keyfile, decoded_keyfile)
}

View File

@ -43,8 +43,8 @@ pub async fn register(
tx: RegistrationSender,
kill_rx: oneshot::Receiver<bool>,
ip: String,
ws_networking: (Option<tokio::net::TcpListener>, bool),
tcp_networking: (Option<tokio::net::TcpListener>, bool),
ws_networking: (Option<&tokio::net::TcpListener>, bool),
tcp_networking: (Option<&tokio::net::TcpListener>, bool),
http_port: u16,
keyfile: Option<Vec<u8>>,
maybe_rpc: Option<String>,
@ -55,12 +55,12 @@ pub async fn register(
let tx = Arc::new(tx);
let ws_port = match ws_networking.0 {
Some(ref listener) => listener.local_addr().unwrap().port(),
Some(listener) => listener.local_addr().unwrap().port(),
None => 0,
};
let ws_flag_used = ws_networking.1;
let tcp_port = match tcp_networking.0 {
Some(ref listener) => listener.local_addr().unwrap().port(),
Some(listener) => listener.local_addr().unwrap().port(),
None => 0,
};
let tcp_flag_used = tcp_networking.1;
@ -258,8 +258,6 @@ pub async fn register(
let _ = open::that(format!("http://localhost:{}/", http_port));
warp::serve(routes)
.bind_with_graceful_shutdown(([0, 0, 0, 0], http_port), async {
drop(ws_networking.0);
drop(tcp_networking.0);
kill_rx.await.ok();
})
.1