shut down OpenOfferManager thread pool before completing shut down

This commit is contained in:
woodser 2024-01-17 20:36:24 -05:00
parent 7beae49dd2
commit e956114239

View File

@ -324,6 +324,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
// Force broadcaster to send out immediately, otherwise we could have a 2 sec delay until the // Force broadcaster to send out immediately, otherwise we could have a 2 sec delay until the
// bundled messages sent out. // bundled messages sent out.
broadcaster.flush(); broadcaster.flush();
shutDownThreadPool();
if (completeHandler != null) { if (completeHandler != null) {
// For typical number of offers we are tolerant with delay to give enough time to broadcast. // For typical number of offers we are tolerant with delay to give enough time to broadcast.
@ -335,12 +336,18 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
}, THREAD_ID); }, THREAD_ID);
} else { } else {
broadcaster.flush(); broadcaster.flush();
shutDownThreadPool();
if (completeHandler != null) if (completeHandler != null)
completeHandler.run(); completeHandler.run();
} }
}
// shut down pool private void shutDownThreadPool() {
ThreadUtils.shutDown(THREAD_ID, SHUTDOWN_TIMEOUT_MS); try {
ThreadUtils.shutDown(THREAD_ID, SHUTDOWN_TIMEOUT_MS);
} catch (Exception e) {
log.error("Error shutting down OpenOfferManager thread pool", e);
}
} }
public void removeAllOpenOffers(@Nullable Runnable completeHandler) { public void removeAllOpenOffers(@Nullable Runnable completeHandler) {