Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Aug 15, 2023
1 parent 5118101 commit 844a50b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/wasi/src/preview2/host/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ impl<T: WasiView> tcp::Host for T {
let network = table.get_network(network)?;
let binder = network.0.tcp_binder(local_address)?;

eprintln!("@@ start_bind");
let clone = socket.clone();
let join = spawn_blocking(move || {
eprintln!("@@ host bind...");
let result = binder.bind_existing_tcp_listener(clone.tcp_socket());
dbg!(&result);
*clone.0.result.lock().unwrap() = Some(result);
clone.0.sender.send(()).unwrap();
eprintln!("@@ bind task done");
});

*tcp_state = HostTcpState::Bind(join);
Expand All @@ -58,10 +62,13 @@ impl<T: WasiView> tcp::Host for T {
};

if join.is_finished() {
eprintln!("@@ finish_bind");
socket.0.result.lock().unwrap().take().unwrap()?;
*tcp_state = HostTcpState::Bound;
eprintln!("@@ finish_bind done");
Ok(())
} else {
eprintln!("@@ bind isn't ready yet!!!");
Err(ErrorCode::WouldBlock.into())
}
}
Expand Down

0 comments on commit 844a50b

Please sign in to comment.