Merge pull request #1983 from ethcore/ipc-rel-dir
Use relative path for IPC sockets
This commit is contained in:
@@ -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 = base_path.to_owned();
|
||||
path.push("parity-chain.ipc");
|
||||
let socket_addr = format!("ipc://{}", path.to_string_lossy());
|
||||
::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());
|
||||
|
||||
Reference in New Issue
Block a user