Removing additional thread from JSON-RPC
This commit is contained in:
parent
1f9eb97d0a
commit
a52043d5b3
@ -594,10 +594,8 @@ impl Configuration {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let rpc_handle = rpc_server.map(|server| {
|
||||
panic_handler.forward_from(&server);
|
||||
server
|
||||
}).map(|server| {
|
||||
let url = format!("{}:{}",
|
||||
match self.args.flag_rpcaddr.as_ref().unwrap_or(&self.args.flag_jsonrpc_interface).as_str() {
|
||||
"all" => "0.0.0.0",
|
||||
|
@ -33,8 +33,6 @@ extern crate ethminer;
|
||||
extern crate transient_hashmap;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use util::panics::{MayPanic, PanicHandler, OnPanicListener};
|
||||
use self::jsonrpc_core::{IoHandler, IoDelegate};
|
||||
|
||||
pub use jsonrpc_http_server::{Listening, RpcServerError};
|
||||
@ -43,7 +41,6 @@ pub mod v1;
|
||||
/// Http server.
|
||||
pub struct RpcServer {
|
||||
handler: Arc<IoHandler>,
|
||||
panic_handler: Arc<PanicHandler>
|
||||
}
|
||||
|
||||
impl RpcServer {
|
||||
@ -51,7 +48,6 @@ impl RpcServer {
|
||||
pub fn new() -> RpcServer {
|
||||
RpcServer {
|
||||
handler: Arc::new(IoHandler::new()),
|
||||
panic_handler: PanicHandler::new_in_arc(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,20 +60,8 @@ impl RpcServer {
|
||||
pub fn start_http(&self, addr: &str, cors_domain: &str, threads: usize) -> Result<Listening, RpcServerError> {
|
||||
let addr = addr.to_owned();
|
||||
let cors_domain = cors_domain.to_owned();
|
||||
let ph = self.panic_handler.clone();
|
||||
let server = jsonrpc_http_server::Server::new(self.handler.clone());
|
||||
|
||||
thread::Builder::new().name("jsonrpc_http".to_string()).spawn(move || {
|
||||
ph.catch_panic(move || {
|
||||
server.start(addr.as_ref(), jsonrpc_http_server::AccessControlAllowOrigin::Value(cors_domain), threads)
|
||||
}).unwrap()
|
||||
}).expect("Error while creating jsonrpc http thread").join().unwrap()
|
||||
server.start(addr.as_ref(), jsonrpc_http_server::AccessControlAllowOrigin::Value(cors_domain), threads)
|
||||
}
|
||||
}
|
||||
|
||||
impl MayPanic for RpcServer {
|
||||
fn on_panic<F>(&self, closure: F) where F: OnPanicListener {
|
||||
self.panic_handler.on_panic(closure);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user