add_sync_notifier in EthPubSubClient holds on to a Client for too long (#10689)

Need a weak ref so shutdown works
This commit is contained in:
David 2019-05-23 07:50:45 +02:00 committed by GitHub
parent 26d1303034
commit d250f348a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -64,13 +64,15 @@ impl<C> EthPubSubClient<C>
where
F: 'static + Fn(SyncState) -> Option<pubsub::PubSubSyncStatus> + Send
{
let handler = self.handler.clone();
let weak_handler = Arc::downgrade(&self.handler);
self.handler.executor.spawn(
receiver.for_each(move |state| {
if let Some(status) = f(state) {
handler.notify_syncing(status);
return Ok(())
if let Some(handler) = weak_handler.upgrade() {
handler.notify_syncing(status);
return Ok(())
}
}
Err(())
})