polling & connection timeouts (#1910)

This commit is contained in:
Nikolay Volf 2016-08-10 22:07:01 +03:00 committed by Gav Wood
parent 417b70f90f
commit 588529e578
2 changed files with 5 additions and 7 deletions

View File

@ -27,8 +27,8 @@ use std::sync::*;
use nanomsg::{Socket, Protocol, Error, Endpoint, PollRequest, PollFd, PollInOut}; use nanomsg::{Socket, Protocol, Error, Endpoint, PollRequest, PollFd, PollInOut};
use std::ops::Deref; use std::ops::Deref;
const POLL_TIMEOUT: isize = 100; const POLL_TIMEOUT: isize = 200;
const CLIENT_CONNECTION_TIMEOUT: isize = 2500; const CLIENT_CONNECTION_TIMEOUT: isize = 15000;
/// Generic worker to handle service (binded) sockets /// Generic worker to handle service (binded) sockets
pub struct Worker<S: ?Sized> where S: IpcInterface { pub struct Worker<S: ?Sized> where S: IpcInterface {
@ -68,7 +68,6 @@ pub fn init_duplex_client<S>(socket_addr: &str) -> Result<GuardedSocket<S>, Sock
SocketError::DuplexLink SocketError::DuplexLink
})); }));
// 2500 ms default timeout
socket.set_receive_timeout(CLIENT_CONNECTION_TIMEOUT).unwrap(); socket.set_receive_timeout(CLIENT_CONNECTION_TIMEOUT).unwrap();
let endpoint = try!(socket.connect(socket_addr).map_err(|e| { let endpoint = try!(socket.connect(socket_addr).map_err(|e| {
@ -91,7 +90,6 @@ pub fn init_client<S>(socket_addr: &str) -> Result<GuardedSocket<S>, SocketError
SocketError::RequestLink SocketError::RequestLink
})); }));
// 2500 ms default timeout
socket.set_receive_timeout(CLIENT_CONNECTION_TIMEOUT).unwrap(); socket.set_receive_timeout(CLIENT_CONNECTION_TIMEOUT).unwrap();
let endpoint = try!(socket.connect(socket_addr).map_err(|e| { let endpoint = try!(socket.connect(socket_addr).map_err(|e| {

View File

@ -80,9 +80,6 @@ pub struct RunCmd {
} }
pub fn execute(cmd: RunCmd) -> Result<(), String> { pub fn execute(cmd: RunCmd) -> Result<(), String> {
// create supervisor
let mut hypervisor = modules::hypervisor();
// increase max number of open files // increase max number of open files
raise_fd_limit(); raise_fd_limit();
@ -165,6 +162,9 @@ pub fn execute(cmd: RunCmd) -> Result<(), String> {
net_conf.boot_nodes = spec.nodes.clone(); net_conf.boot_nodes = spec.nodes.clone();
} }
// create supervisor
let mut hypervisor = modules::hypervisor();
// create client service. // create client service.
let service = try!(ClientService::start( let service = try!(ClientService::start(
client_config, client_config,