fix to use relative socket path

This commit is contained in:
Nikolay Volf
2016-08-22 19:41:58 +03:00
parent 880b7b811e
commit 7c5435d3bb
11 changed files with 95 additions and 24 deletions

View File

@@ -60,6 +60,7 @@ impl ClientService {
config: ClientConfig,
spec: &Spec,
db_path: &Path,
ipc_path: &Path,
miner: Arc<Miner>,
) -> Result<ClientService, Error>
{
@@ -86,7 +87,7 @@ impl ClientService {
try!(io_service.register_handler(client_io));
let stop_guard = ::devtools::StopGuard::new();
run_ipc(client.clone(), stop_guard.share());
run_ipc(ipc_path, client.clone(), stop_guard.share());
Ok(ClientService {
io_service: Arc::new(io_service),
@@ -167,10 +168,13 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
}
#[cfg(feature="ipc")]
fn run_ipc(client: Arc<Client>, stop: Arc<AtomicBool>) {
fn run_ipc(base_path: &Path, client: Arc<Client>, stop: Arc<AtomicBool>) {
let mut path = ::std::path::PathBuf::from(base_path);
path.push("parity-chain.ipc");
let socket_addr = format!("ipc://{}", path.to_str().unwrap());
::std::thread::spawn(move || {
let mut worker = nanoipc::Worker::new(&(client as Arc<BlockChainClient>));
worker.add_reqrep("ipc:///tmp/parity-chain.ipc").expect("Ipc expected to initialize with no issues");
worker.add_reqrep(&socket_addr).expect("Ipc expected to initialize with no issues");
while !stop.load(::std::sync::atomic::Ordering::Relaxed) {
worker.poll();
@@ -179,7 +183,7 @@ fn run_ipc(client: Arc<Client>, stop: Arc<AtomicBool>) {
}
#[cfg(not(feature="ipc"))]
fn run_ipc(_client: Arc<Client>, _stop: Arc<AtomicBool>) {
fn run_ipc(_base_path: &Path, _client: Arc<Client>, _stop: Arc<AtomicBool>) {
}
#[cfg(test)]
@@ -203,6 +207,7 @@ mod tests {
ClientConfig::default(),
&spec,
&path,
&path,
Arc::new(Miner::with_spec(&spec)),
);
assert!(service.is_ok());