From cd97b9c3e891e861c7d11fb1733274ff433f759d Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 23 Feb 2022 12:47:44 +1100 Subject: [PATCH] minor fix on poller threading --- .../Sending & Receiving/Pollers/Poller.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift b/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift index 8885e5542..623acf1ff 100644 --- a/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift +++ b/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift @@ -71,16 +71,18 @@ public final class Poller : NSObject { // randomElement() uses the system's default random generator, which is cryptographically secure let nextSnode = unusedSnodes.randomElement()! usedSnodes.insert(nextSnode) - poll(nextSnode, seal: seal).done(on: Threading.pollerQueue) { + poll(nextSnode, seal: seal).done2 { seal.fulfill(()) - }.catch(on: Threading.pollerQueue) { [weak self] error in + }.catch2 { [weak self] error in if let error = error as? Error, error == .pollLimitReached { self?.pollCount = 0 } else { SNLog("Polling \(nextSnode) failed; dropping it and switching to next snode.") SnodeAPI.dropSnodeFromSwarmIfNeeded(nextSnode, publicKey: userPublicKey) } - self?.pollNextSnode(seal: seal) + Threading.pollerQueue.async { + self?.pollNextSnode(seal: seal) + } } } else { seal.fulfill(())