Join http api on shutdown
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use super::proto;
|
||||
use super::ExtraInsertsConf;
|
||||
use crate::senderpolling::SenderPolling;
|
||||
use crate::throttletrace::ThrottleTrace;
|
||||
use crate::timebin::ConnTimeBin;
|
||||
use async_channel::Sender;
|
||||
use core::fmt;
|
||||
@@ -477,6 +478,7 @@ pub struct CaConn {
|
||||
channel_info_query_queue: VecDeque<ChannelInfoQuery>,
|
||||
channel_info_query_sending: SenderPolling<ChannelInfoQuery>,
|
||||
time_binners: BTreeMap<Cid, ConnTimeBin>,
|
||||
thr_msg_poll: ThrottleTrace,
|
||||
}
|
||||
|
||||
impl Drop for CaConn {
|
||||
@@ -525,6 +527,7 @@ impl CaConn {
|
||||
channel_info_query_queue: VecDeque::new(),
|
||||
channel_info_query_sending: SenderPolling::new(channel_info_query_tx),
|
||||
time_binners: BTreeMap::new(),
|
||||
thr_msg_poll: ThrottleTrace::new(Duration::from_millis(10000)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1708,7 +1711,7 @@ impl CaConn {
|
||||
}
|
||||
|
||||
fn handle_own_ticker_tick(self: Pin<&mut Self>, _cx: &mut Context) -> Result<(), Error> {
|
||||
debug!("tick CaConn {}", self.remote_addr_dbg);
|
||||
// debug!("tick CaConn {}", self.remote_addr_dbg);
|
||||
let this = self.get_mut();
|
||||
if false {
|
||||
for (_, tb) in this.time_binners.iter_mut() {
|
||||
@@ -1759,6 +1762,7 @@ impl Stream for CaConn {
|
||||
self.stats.caconn_poll_count.inc();
|
||||
let poll_ts1 = Instant::now();
|
||||
let ret = loop {
|
||||
self.thr_msg_poll.trigger("CaConn::poll_next");
|
||||
break if let CaConnState::EndOfStream = self.state {
|
||||
Ready(None)
|
||||
} else if let Err(e) = self.as_mut().handle_own_ticker(cx) {
|
||||
@@ -1819,7 +1823,7 @@ impl Stream for CaConn {
|
||||
warn!("long poll duration {:.0} ms", dt.as_secs_f32() * 1e3)
|
||||
} else if dt > Duration::from_millis(40) {
|
||||
info!("long poll duration {:.0} ms", dt.as_secs_f32() * 1e3)
|
||||
} else if dt > Duration::from_millis(5) {
|
||||
} else if false && dt > Duration::from_millis(5) {
|
||||
debug!("long poll duration {:.0} ms", dt.as_secs_f32() * 1e3)
|
||||
}
|
||||
ret
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use super::connset_input_merge::InputMerge;
|
||||
use super::findioc::FindIocRes;
|
||||
use super::statemap;
|
||||
use super::statemap::ChannelState;
|
||||
@@ -16,6 +15,7 @@ use crate::errconv::ErrConv;
|
||||
use crate::rt::JoinHandle;
|
||||
use crate::rt::TokMx;
|
||||
use crate::senderpolling::SenderPolling;
|
||||
use crate::throttletrace::ThrottleTrace;
|
||||
use async_channel::Receiver;
|
||||
use async_channel::Sender;
|
||||
use atomic::AtomicUsize;
|
||||
@@ -260,6 +260,8 @@ pub struct CaConnSet {
|
||||
stats: CaConnSetStats,
|
||||
ioc_finder_jh: JoinHandle<Result<(), Error>>,
|
||||
await_ca_conn_jhs: VecDeque<(SocketAddr, JoinHandle<Result<(), Error>>)>,
|
||||
thr_msg_poll_1: ThrottleTrace,
|
||||
thr_msg_storage_len: ThrottleTrace,
|
||||
}
|
||||
|
||||
impl CaConnSet {
|
||||
@@ -304,6 +306,8 @@ impl CaConnSet {
|
||||
// connset_out_sender: SenderPolling::new(connset_out_tx),
|
||||
ioc_finder_jh,
|
||||
await_ca_conn_jhs: VecDeque::new(),
|
||||
thr_msg_poll_1: ThrottleTrace::new(Duration::from_millis(2000)),
|
||||
thr_msg_storage_len: ThrottleTrace::new(Duration::from_millis(1000)),
|
||||
};
|
||||
// TODO await on jh
|
||||
let jh = tokio::spawn(CaConnSet::run(connset));
|
||||
@@ -555,6 +559,8 @@ impl CaConnSet {
|
||||
if self.shutdown_stopping {
|
||||
return Ok(());
|
||||
}
|
||||
self.thr_msg_storage_len
|
||||
.trigger_fmt("msg", &[&self.storage_insert_sender.len()]);
|
||||
debug!("TODO handle_check_health");
|
||||
let ts2 = Instant::now();
|
||||
let item = CaConnSetItem::Healthy(ts1, ts2);
|
||||
@@ -636,7 +642,7 @@ impl CaConnSet {
|
||||
tx: Sender<(SocketAddr, CaConnEvent)>,
|
||||
addr: SocketAddr,
|
||||
) -> Result<(), Error> {
|
||||
debug!("ca_conn_consumer begin {}", addr);
|
||||
trace2!("ca_conn_consumer begin {}", addr);
|
||||
let stats = conn.stats();
|
||||
let mut conn = conn;
|
||||
let mut ret = Ok(());
|
||||
@@ -652,7 +658,7 @@ impl CaConnSet {
|
||||
}
|
||||
}
|
||||
}
|
||||
debug!("ca_conn_consumer ended {}", addr);
|
||||
trace2!("ca_conn_consumer ended {}", addr);
|
||||
tx.send((
|
||||
addr,
|
||||
CaConnEvent {
|
||||
@@ -661,7 +667,7 @@ impl CaConnSet {
|
||||
},
|
||||
))
|
||||
.await?;
|
||||
debug!("ca_conn_consumer signaled {}", addr);
|
||||
trace!("ca_conn_consumer signaled {}", addr);
|
||||
ret
|
||||
}
|
||||
|
||||
@@ -980,8 +986,9 @@ impl Stream for CaConnSet {
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
use Poll::*;
|
||||
debug!("CaConnSet::poll");
|
||||
loop {
|
||||
self.thr_msg_poll_1.trigger("CaConnSet");
|
||||
|
||||
let mut have_pending = false;
|
||||
|
||||
if let Some(item) = self.connset_out_queue.pop_front() {
|
||||
|
||||
Reference in New Issue
Block a user