diff --git a/autopush_rs/src/client.rs b/autopush_rs/src/client.rs index a1615755..79f65a5f 100644 --- a/autopush_rs/src/client.rs +++ b/autopush_rs/src/client.rs @@ -712,7 +712,7 @@ where pub fn shutdown(&mut self) { // If we made it past hello, do more cleanup - let webpush = match self.webpush.take() { + let mut webpush = match self.webpush.take() { Some(webpush) => webpush, None => return }; @@ -730,6 +730,20 @@ where .send() .ok(); + // If there's any notifications in the queue, move them to our unacked direct notifs + webpush.rx.close(); + // wait() is ok as the queue is closed at this point. + let rx_iter = webpush.rx.wait(); + for msg in rx_iter { + match msg { + Ok(ServerNotification::CheckStorage) => continue, + Ok(ServerNotification::Notification(notif)) => { + webpush.unacked_direct_notifs.push(notif); + } + Err(_) => continue, + } + } + // If there's direct unack'd messages, they need to be saved out without blocking // here self.srv.disconnet_client(&webpush.uaid);