From a9b083e5858f479cd64210d3f12ea961f182c780 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Thu, 24 Jan 2019 12:46:40 -0800 Subject: [PATCH] Set fetch stage socket non blocking to false while during recv (#2542) * Set fetch stage socket non blocking to false while during recv * remove ProgramError changes from this PR --- src/bank.rs | 3 ++- src/fetch_stage.rs | 2 +- src/packet.rs | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bank.rs b/src/bank.rs index 25e080763f..0020dce7f8 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -654,7 +654,8 @@ impl Bank { } Ok(()) } - pub fn par_execute_entries(&self, entries: &[(&Entry, Vec>)]) -> Result<()> { + + fn par_execute_entries(&self, entries: &[(&Entry, Vec>)]) -> Result<()> { inc_new_counter_info!("bank-par_execute_entries-count", entries.len()); let results: Vec> = entries .into_par_iter() diff --git a/src/fetch_stage.rs b/src/fetch_stage.rs index 3638e0d445..76550b0e65 100644 --- a/src/fetch_stage.rs +++ b/src/fetch_stage.rs @@ -19,7 +19,7 @@ impl FetchStage { let tx_sockets = sockets.into_iter().map(Arc::new).collect(); Self::new_multi_socket(tx_sockets, exit) } - pub fn new_multi_socket( + fn new_multi_socket( sockets: Vec>, exit: Arc, ) -> (Self, PacketReceiver) { diff --git a/src/packet.rs b/src/packet.rs index 76d0f81384..f44235795e 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -182,7 +182,6 @@ impl Packets { Err(_) if i > 0 => { inc_new_counter_info!("packets-recv_count", i); debug!("got {:?} messages on {}", i, socket.local_addr().unwrap()); - socket.set_nonblocking(true)?; return Ok(i); } Err(e) => { @@ -190,10 +189,12 @@ impl Packets { return Err(Error::IO(e)); } Ok(npkts) => { + if i == 0 { + socket.set_nonblocking(true)?; + } trace!("got {} packets", npkts); i += npkts; - if npkts != NUM_RCVMMSGS { - socket.set_nonblocking(true)?; + if npkts != NUM_RCVMMSGS || i >= 1024 { inc_new_counter_info!("packets-recv_count", i); return Ok(i); }