Ipc serialization & protocol fixes (#1188)
* serialization and codegen fixes from branch * nano lib fixes * fixes error encoding & comment * another comment fix * client timeout -> const
This commit is contained in:
@@ -30,6 +30,7 @@ use nanomsg::{Socket, Protocol, Error, Endpoint, PollRequest, PollFd, PollInOut}
|
||||
use std::ops::Deref;
|
||||
|
||||
const POLL_TIMEOUT: isize = 100;
|
||||
const CLIENT_CONNECTION_TIMEOUT: isize = 2500;
|
||||
|
||||
/// Generic worker to handle service (binded) sockets
|
||||
pub struct Worker<S> where S: IpcInterface<S> {
|
||||
@@ -46,6 +47,12 @@ pub struct GuardedSocket<S> where S: WithSocket<Socket> {
|
||||
_endpoint: Endpoint,
|
||||
}
|
||||
|
||||
impl<S> GuardedSocket<S> where S: WithSocket<Socket> {
|
||||
pub fn service(&self) -> Arc<S> {
|
||||
self.client.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> Deref for GuardedSocket<S> where S: WithSocket<Socket> {
|
||||
type Target = S;
|
||||
|
||||
@@ -63,6 +70,9 @@ pub fn init_duplex_client<S>(socket_addr: &str) -> Result<GuardedSocket<S>, Sock
|
||||
SocketError::DuplexLink
|
||||
}));
|
||||
|
||||
// 2500 ms default timeout
|
||||
socket.set_receive_timeout(CLIENT_CONNECTION_TIMEOUT).unwrap();
|
||||
|
||||
let endpoint = try!(socket.connect(socket_addr).map_err(|e| {
|
||||
warn!(target: "ipc", "Failed to bind socket to address '{}': {:?}", socket_addr, e);
|
||||
SocketError::DuplexLink
|
||||
@@ -83,6 +93,9 @@ pub fn init_client<S>(socket_addr: &str) -> Result<GuardedSocket<S>, SocketError
|
||||
SocketError::RequestLink
|
||||
}));
|
||||
|
||||
// 2500 ms default timeout
|
||||
socket.set_receive_timeout(CLIENT_CONNECTION_TIMEOUT).unwrap();
|
||||
|
||||
let endpoint = try!(socket.connect(socket_addr).map_err(|e| {
|
||||
warn!(target: "ipc", "Failed to bind socket to address '{}': {:?}", socket_addr, e);
|
||||
SocketError::RequestLink
|
||||
|
||||
Reference in New Issue
Block a user