simplify sender shutdown; prevent launching any retries
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
b7df0a14c6
commit
ef9b1c6303
1 changed files with 13 additions and 10 deletions
|
@ -7,7 +7,7 @@ use std::{
|
||||||
|
|
||||||
use base64::{engine::general_purpose, Engine as _};
|
use base64::{engine::general_purpose, Engine as _};
|
||||||
use conduit::{
|
use conduit::{
|
||||||
debug, debug_warn, err, error,
|
debug, err, error,
|
||||||
result::LogErr,
|
result::LogErr,
|
||||||
trace,
|
trace,
|
||||||
utils::{calculate_hash, math::continue_exponential_backoff_secs, ReadyExt},
|
utils::{calculate_hash, math::continue_exponential_backoff_secs, ReadyExt},
|
||||||
|
@ -35,7 +35,6 @@ use ruma::{
|
||||||
RoomVersionId, ServerName, UInt,
|
RoomVersionId, ServerName, UInt,
|
||||||
};
|
};
|
||||||
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
|
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
|
||||||
use tokio::time::sleep_until;
|
|
||||||
|
|
||||||
use super::{appservice, data::QueueItem, Destination, Msg, SendingEvent, Service};
|
use super::{appservice, data::QueueItem, Destination, Msg, SendingEvent, Service};
|
||||||
|
|
||||||
|
@ -81,7 +80,7 @@ impl Service {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.finish_responses(&mut futures, &mut statuses).await;
|
self.finish_responses(&mut futures).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -146,24 +145,28 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn finish_responses<'a>(&'a self, futures: &mut SendingFutures<'a>, statuses: &mut CurTransactionStatus) {
|
async fn finish_responses<'a>(&'a self, futures: &mut SendingFutures<'a>) {
|
||||||
|
use tokio::{
|
||||||
|
select,
|
||||||
|
time::{sleep_until, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let timeout = Duration::from_millis(CLEANUP_TIMEOUT_MS);
|
let timeout = Duration::from_millis(CLEANUP_TIMEOUT_MS);
|
||||||
let deadline = now.checked_add(timeout).unwrap_or(now);
|
let deadline = now.checked_add(timeout).unwrap_or(now);
|
||||||
loop {
|
loop {
|
||||||
trace!("Waiting for {} requests to complete...", futures.len());
|
trace!("Waiting for {} requests to complete...", futures.len());
|
||||||
tokio::select! {
|
select! {
|
||||||
() = sleep_until(deadline.into()) => break,
|
() = sleep_until(deadline) => return,
|
||||||
response = futures.next() => match response {
|
response = futures.next() => match response {
|
||||||
Some(response) => self.handle_response(response, futures, statuses).await,
|
Some(Ok(dest)) => self.db.delete_all_active_requests_for(&dest).await,
|
||||||
|
Some(_) => continue,
|
||||||
None => return,
|
None => return,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_warn!("Leaving with {} unfinished requests...", futures.len());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(clippy::needless_pass_by_ref_mut)]
|
#[allow(clippy::needless_pass_by_ref_mut)]
|
||||||
async fn initial_requests<'a>(&'a self, futures: &mut SendingFutures<'a>, statuses: &mut CurTransactionStatus) {
|
async fn initial_requests<'a>(&'a self, futures: &mut SendingFutures<'a>, statuses: &mut CurTransactionStatus) {
|
||||||
let keep = usize::try_from(self.server.config.startup_netburst_keep).unwrap_or(usize::MAX);
|
let keep = usize::try_from(self.server.config.startup_netburst_keep).unwrap_or(usize::MAX);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue