Skip to content

Commit

Permalink
Peerd: set zmq immediate=true and linger=0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCharlatan committed May 30, 2022
1 parent 34574ec commit fd664ea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/peerd/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ pub fn run(

debug!("Opening bridge between runtime and peer receiver threads");
let rx = ZMQ_CONTEXT.socket(zmq::PAIR)?;
rx.set_linger(0)?;
rx.set_immediate(true)?;
rx.bind("inproc://bridge")?;
let tx = ZMQ_CONTEXT.socket(zmq::PAIR)?;
tx.set_linger(0)?;
tx.connect("inproc://bridge")?;

let (thread_flag_tx, _thread_flag_rx) = std::sync::mpsc::channel();
Expand Down Expand Up @@ -552,6 +555,9 @@ fn restart_receiver_runtime(
let tx = ZMQ_CONTEXT
.socket(zmq::PAIR)
.expect("unable to create new bridge zmq socket");
tx.set_linger(0).unwrap();
// set immediate to true to report errors in case the connection cannot actually send
tx.set_immediate(true).unwrap();
tx.connect("inproc://bridge")
.expect("unable to connec to zmq bridge");

Expand Down

0 comments on commit fd664ea

Please sign in to comment.