diff --git a/src/core/instance/mod.rs b/src/core/instance/mod.rs index 7e7a995..b42fb76 100644 --- a/src/core/instance/mod.rs +++ b/src/core/instance/mod.rs @@ -292,6 +292,13 @@ impl Instance { runtime_inner.spawn(func); } + #[cfg(feature = "async")] + pub fn spawn_async_blocking + Send + Sync + 'static>(&mut self, name: &str, func: F) { + self.threads.push(name.to_owned()); + let runtime_inner = self.runtime.lock().unwrap(); + runtime_inner.block_on(func); + } + pub fn wait(&self) { loop { thread::sleep_ms(10000000) diff --git a/src/platform/os/mod.rs b/src/platform/os/mod.rs index f7b75fa..a511683 100644 --- a/src/platform/os/mod.rs +++ b/src/platform/os/mod.rs @@ -78,6 +78,7 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> { // if the store is already opened, connect to the instance, that opened it and join // it's namespace info!("CONNECTING"); + unix_socket::connect(instance, store_path.into())?; return Ok(()); } else { diff --git a/src/platform/os/unix_socket.rs b/src/platform/os/unix_socket.rs index 67eb689..1317822 100644 --- a/src/platform/os/unix_socket.rs +++ b/src/platform/os/unix_socket.rs @@ -25,15 +25,17 @@ impl UnixListener { pub fn connect(instance: &mut Instance, store_path: PathBuf) -> MizeResult<()> { - instance.spawn_async("unix_connection", connect_async(instance.clone(), store_path) ); + instance.spawn_async_blocking("unix_connection", connect_async(instance.clone(), store_path) ); Ok(()) } async fn connect_async(mut instance: Instance, store_path: PathBuf) -> MizeResult<()> { - let mut stream = UnixStream::connect(store_path).await?; + println!("we are never hereeeeeeeeeeeeee"); + let mut stream = UnixStream::connect(store_path.join("sock")).await?; let (read_half, write_half) = stream.split(); + println!("we are never hoooooooooooooooooooooooooooooo"); let (recieve_tx, recieve_rx) = unbounded::(); let (send_tx, send_rx) = unbounded::(); @@ -59,7 +61,7 @@ impl ConnListener for UnixListener { async fn unix_listen(listener: UnixListener, mut instance: Instance) -> MizeResult<()> { // remove the file at sock_path if it already exists - fs::remove_file(&listener.sock_path)?; + fs::remove_file(&listener.sock_path); let listener = TokioUnixListener::bind(&listener.sock_path) .mize_result_msg(format!("Could not bind to unix socket at '{}'", listener.sock_path.display()))?; @@ -67,6 +69,7 @@ async fn unix_listen(listener: UnixListener, mut instance: Instance) -> MizeResu loop { let (mut unix_sock, addr) = listener.accept().await .mize_result_msg("Error while accepting Unix sock connection")?; + info!("new connection"); let (recieve_tx, recieve_rx) = unbounded::(); let (send_tx, send_rx) = unbounded::();