Skip to content

Commit

Permalink
[RSDK-8258] Failed periodic app client tasks should drop the client (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
acmorrow authored Jul 24, 2024
1 parent 6ba8d43 commit d5f7e23
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions micro-rdk/src/common/conn/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,21 @@ where
// duration, update `duration`. Otherwise, just sleep again and hope that an
// `AppClient` will be available on the next wakeup.
let _ = async_io::Timer::after(duration).await;
let rguard = app_client.read().await;
for app_client in rguard.as_ref().iter() {
let urguard = app_client.upgradable_read().await;
for app_client in urguard.as_ref().iter() {
match task.invoke(app_client).await {
Ok(None) => continue,
Ok(Some(next_duration)) => {
duration = next_duration;
}
Err(e) => {
log::error!(
"Periodic task {} failed with error {}",
"Periodic task {} failed with error {:?} - dropping app client",
task.name(),
e
);
let _ = AsyncRwLockUpgradableReadGuard::upgrade(urguard).await.take();
break;
}
}
}
Expand Down

0 comments on commit d5f7e23

Please sign in to comment.