Skip to content

Commit

Permalink
Merge pull request #3 from golemfactory/sz/add_inproc_communication
Browse files Browse the repository at this point in the history
Sz/add inproc communication
  • Loading branch information
scx1332 authored Mar 22, 2022
2 parents dc27508 + c490c9f commit 696c97f
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 25 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ edition = "2021"

[dependencies]
env_logger = {version = "^0.9", optional = true }
log4rs = {version = "^1.0", optional = true }
structopt = {version = "^0.3", optional = true }
log4rs = {version = "^1.0"}
structopt = {version = "^0.3", optional = true}
filetime = "^0.2"
tokio = { version = "^1.10", features = ["full"] }
tokio-stream = { version = "^0.1", features = ["fs"] }
Expand All @@ -26,7 +26,7 @@ bytes = "^1.1"
name = "ya_vm_file_server"

[features]
build-binary = ["env_logger", "log4rs", "structopt"]
build-binary = ["env_logger", "structopt"]

[[bin]]
name = "ya-vm-file-server"
Expand All @@ -36,3 +36,4 @@ required-features = ["build-binary"]
# packages used in integration tests
[dev-dependencies]
filesystem-rs = { path = "tests/filesystem-rs" }
tempdir = "0.3.7"
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Author of original implementation: Ryo Munakata

## why separate project

We have to fork this library to enable cross-platform capabilities of p9 server.
We have to fork this library to enable cross-platform capabilities of p9 server.
Original implementation worked only of Linux filesystem.
* Emulating unix attributes
* Maximum separation between server filesystem and client filesystem
* Similar behaviour when served on Linux and Windows machine.
* Similar behavior when served on Linux and Windows machine.

## Build

Expand Down Expand Up @@ -47,22 +47,22 @@ docker-compose up
### Integration tests
Tests are half-automatic. First you need to prepare an environment:
1) Launch 9p server:

```
RUST_LOG=debug cargo run -- --mount-point tests/9p_mnt_point
RUST_LOG=debug cargo run --features="build-binary" -- --mount-point tests/9p_mnt_point
```

3) On other shell mount to the server:
```

```
cd tests
sudo mount -t 9p -o version=9p2000.L,trans=tcp,debug=0x04,port=7878,uname=testuser 127.0.0.1 ./mnt_tests
```

4) Launch tests using **nightly** build:

```
cargo +nightly test
cargo +nightly test
```

You should be able to see logging on the server side while tests are running.
Expand Down
16 changes: 14 additions & 2 deletions src/core/srv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//! # Protocol
//! 9P2000.L
use tokio::io::DuplexStream;

use {
super::{error, error::errno::*, fcall::*, lib_utils::Result, serialize},
async_trait::async_trait,
Expand Down Expand Up @@ -342,7 +344,7 @@ where
let bytes = bytes?;

let msg = serialize::read_msg(&mut bytes.reader())?;
log::info!("\t← {:?}", msg);
log::debug!("\t← {:?}", msg);

let fids = fsfids.clone();
let fs = filesystem.clone();
Expand Down Expand Up @@ -372,7 +374,7 @@ where
.await
.unwrap();
}
log::info!("\t→ {:?}", response);
log::debug!("\t→ {:?}", response);
}
});
}
Expand Down Expand Up @@ -412,3 +414,13 @@ where
_ => Err(From::from(io_err!(InvalidInput, "Protocol not supported"))),
}
}

/// Main loop of 9p server that uses inproc stream
pub async fn srv_async_inproc<Fs>(filesystem: Fs, server: DuplexStream) -> Result<()>
where
Fs: 'static + Filesystem + Send + Sync + Clone,
{
let (server_rx, server_tx) = tokio::io::split(server);

dispatch(filesystem, server_rx, server_tx).await
}
Loading

0 comments on commit 696c97f

Please sign in to comment.