From f47adfa03f9b8cf0fedb5c66a508cb1750495c65 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 15 Dec 2023 16:56:31 -0500 Subject: [PATCH] change signature of accept function --- veilid-server/src/client_api.rs | 4 ++-- veilid-tools/src/ipc/ipc_tokio/unix.rs | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/veilid-server/src/client_api.rs b/veilid-server/src/client_api.rs index 5bc3cf56..6ddc1ec4 100644 --- a/veilid-server/src/client_api.rs +++ b/veilid-server/src/client_api.rs @@ -456,7 +456,7 @@ impl ClientApi { .await; debug!( - "Closed Client API Connection: {:?} -> {:?}", + "Closed TCP Client API Connection: {:?} -> {:?}", peer_addr, local_addr ); @@ -486,7 +486,7 @@ impl ClientApi { self.run_json_request_processor(reader, writer, stop_token) .await; - debug!("Closed Client API Connection",); + debug!("Closed IPC Client API Connection",); awg.done(); } diff --git a/veilid-tools/src/ipc/ipc_tokio/unix.rs b/veilid-tools/src/ipc/ipc_tokio/unix.rs index 461220b5..8abc434b 100644 --- a/veilid-tools/src/ipc/ipc_tokio/unix.rs +++ b/veilid-tools/src/ipc/ipc_tokio/unix.rs @@ -100,7 +100,7 @@ impl Drop for IpcIncoming { pub struct IpcListener { path: Option, - internal: Option, + internal: Option>, } impl IpcListener { @@ -108,14 +108,20 @@ impl IpcListener { pub async fn bind>(path: P) -> io::Result { Ok(Self { path: Some(path.as_ref().to_path_buf()), - internal: Some(UnixListener::bind(path)?), + internal: Some(Arc::new(UnixListener::bind(path)?)), }) } /// Accepts a new incoming connection to this listener. - pub async fn accept(&self) -> io::Result { - Ok(IpcStream { - internal: self.internal.as_ref().unwrap().accept().await?.0, + pub fn accept(&self) -> SendPinBoxFuture> { + let this = IpcListener { + path: self.path.clone(), + internal: self.internal.clone(), + }; + Box::pin(async move { + Ok(IpcStream { + internal: this.internal.as_ref().unwrap().accept().await?.0, + }) }) } @@ -123,7 +129,9 @@ impl IpcListener { pub fn incoming(mut self) -> IpcIncoming { IpcIncoming { path: self.path.take().unwrap(), - internal: UnixListenerStream::new(self.internal.take().unwrap()), + internal: UnixListenerStream::new( + Arc::into_inner(self.internal.take().unwrap()).unwrap(), + ), } } }