most of getting stuff with two instances works
This commit is contained in:
@@ -27,11 +27,13 @@ impl UnixListener {
|
||||
pub fn connect(instance: &mut Instance, store_path: PathBuf) -> MizeResult<()> {
|
||||
let conn_id = instance.spawn_async_blocking("unix_connection", connect_async(instance.clone(), store_path) )?;
|
||||
|
||||
let ns_of_peer = instance.get(format!("inst/con_by_id/{}/peer/0/config/namespace", conn_id))?.value_string()?;
|
||||
let ns_of_peer_str = instance.get(format!("inst/con_by_id/{}/peer/0/config/namespace", conn_id))?.value_string()?;
|
||||
let ns_of_peer = instance.namespace_from_string(ns_of_peer_str)?;
|
||||
|
||||
info!("connect_async ... ns_of_peer: {}", ns_of_peer);
|
||||
info!("connect_async ... ns_of_peer: {}", ns_of_peer.clone().as_string());
|
||||
|
||||
//instance.connection_set_namespace(conn_id, namespace)
|
||||
instance.connection_set_namespace(conn_id, ns_of_peer.clone());
|
||||
instance.set_namespace(ns_of_peer);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -100,7 +102,7 @@ async fn unix_listen(listener: UnixListener, mut instance: Instance) -> MizeResu
|
||||
let result = unix_incomming(unix_read, cloned_instance, conn_id);
|
||||
// if unix incomming fails, close the connection
|
||||
if let Err(err) = result {
|
||||
warn!("Connection closing, {:?}", err);
|
||||
warn!("Connection closing because of EOF");
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
@@ -110,7 +112,7 @@ async fn unix_listen(listener: UnixListener, mut instance: Instance) -> MizeResu
|
||||
let result = unix_outgoing(unix_write, send_rx, outgoing_cloned_instance, conn_id);
|
||||
// if writing fails, close this connection
|
||||
if let Err(err) = result {
|
||||
warn!("Connection closing, {:?}", err);
|
||||
warn!("Connection closing because of EOF");
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
@@ -130,7 +132,7 @@ fn unix_outgoing(mut unix_write: OwnedWriteHalf, send_rx: Receiver<MizeMessage>,
|
||||
|
||||
fn unix_incomming(mut unix_read: OwnedReadHalf, mut instance: Instance, conn_id: u64) -> MizeResult<()> {
|
||||
loop {
|
||||
println!("unix incoming loop...");
|
||||
//println!("unix incoming loop...");
|
||||
let adapter = MyCiboriumReader { inner: &mut unix_read, instance: &mut instance };
|
||||
let value: CborValue = ciborium::from_reader(adapter)?;
|
||||
if let CborValue::Integer(_) = value {
|
||||
@@ -152,17 +154,17 @@ struct MyCiboriumWriter<'a> {
|
||||
impl<'a> ciborium_io::Write for MyCiboriumWriter<'a> {
|
||||
type Error = MizeError;
|
||||
fn write_all(&mut self, data: &[u8]) -> Result<(), Self::Error> {
|
||||
println!("CALL: write_all");
|
||||
//println!("CALL: write_all");
|
||||
let runtime = self.instance.runtime.lock()?;
|
||||
println!("after runtime");
|
||||
//println!("after runtime");
|
||||
let num_read = runtime.block_on(self.inner.write_all(data))?;
|
||||
Ok(())
|
||||
}
|
||||
fn flush(&mut self) -> Result<(), Self::Error> {
|
||||
println!("CALL flush");
|
||||
//println!("CALL flush");
|
||||
let handle = self.instance.async_get_handle();
|
||||
let result = handle.block_on(self.inner.flush());
|
||||
println!("flush result: {:?}", result);
|
||||
//println!("flush result: {:?}", result);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -173,12 +175,12 @@ struct MyCiboriumReader<'a> {
|
||||
}
|
||||
|
||||
async fn test(test: &mut OwnedReadHalf, buf: &mut [u8]) {
|
||||
println!("hello from async...");
|
||||
println!("len: {}", buf.len());
|
||||
//println!("hello from async...");
|
||||
//println!("len: {}", buf.len());
|
||||
let num_read = test.read_u8().await;
|
||||
println!("num_read: {:?}", num_read);
|
||||
//println!("num_read: {:?}", num_read);
|
||||
//test.read_exact(buf).await;
|
||||
println!("hello from async... twoooooooooooooo");
|
||||
//println!("hello from async... twoooooooooooooo");
|
||||
}
|
||||
|
||||
impl<'a> ciborium_io::Read for MyCiboriumReader<'a> {
|
||||
@@ -192,10 +194,10 @@ impl<'a> ciborium_io::Read for MyCiboriumReader<'a> {
|
||||
|
||||
//return Ok(());
|
||||
|
||||
println!("incoming before block_on");
|
||||
//println!("incoming before block_on");
|
||||
let handle = self.instance.async_get_handle();
|
||||
let num_read = handle.block_on(self.inner.read_exact(data))?;
|
||||
println!("incoming num_read: {:?}", num_read);
|
||||
//println!("incoming num_read: {:?}", num_read);
|
||||
//println!("data after: {:?}", data);
|
||||
|
||||
// if we read 0 bytes, that means the reader stream closed and we should terminate the
|
||||
|
||||
Reference in New Issue
Block a user