Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
feat: drain pending notifications from the client rx queue
Browse files Browse the repository at this point in the history
Closes #1133
  • Loading branch information
bbangert committed Feb 13, 2018
1 parent ffd3a8d commit 00483f7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion autopush_rs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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);
Expand Down

0 comments on commit 00483f7

Please sign in to comment.