Commit a912b21d0811
tarball1 file changed+16-2
@@ -251,6 +251,20 @@ impl TaskContext {
251251
/// had a 399 room account hand most rooms to the event cache four or five times252252
const ROOM_LIST_GROWING_BATCH: u32 = 500;253253
254
+/// how long shutdown waits on the mentions and search services before aborting them with the255
+/// other tasks. a sync response still being processed kept mentions busy for 2 to 3.4s, and the256
+/// next engine can't start until this one is gone257
+const SERVICE_STOP_GRACE: std::time::Duration = std::time::Duration::from_millis(500);258
+259
+async fn stop_within(stop: impl Future<Output = ()>, service: &'static str) {260
+ if matrix_sdk::timeout::timeout(stop, SERVICE_STOP_GRACE)261
+ .await262
+ .is_err()263
+ {264
+ tracing::debug!(service, "a service didn't stop in time and is aborted");265
+ }266
+}267
+254268
/// tasks catch their own panics so each comes back with its context, since joining255269
/// through the sdk's executor gives no task id to look one up by. wasm has nothing to catch256270
fn panic_message(payload: Box<dyn std::any::Any + Send>) -> String {@@ -1242,11 +1256,11 @@ impl Engine {
12421256
self.sync.stop().await;12431257
if self.mentions_service.is_none() {12441258
tracing::debug!(step = "mentions", "engine shutdown step");1245
- self.mentions.stop().await;1259
+ stop_within(self.mentions.stop(), "mentions").await;12461260
}12471261
if self.search_service.is_none() {12481262
tracing::debug!(step = "search", "engine shutdown step");1249
- self.search.stop().await;1263
+ stop_within(self.search.stop(), "search").await;12501264
}12511265
tracing::debug!(step = "tasks", "engine shutdown step");12521266
self.tasks.shutdown().await;