release lock processing offers before callback

This commit is contained in:
woodser 2024-08-01 09:41:34 -04:00
parent 76f8f85487
commit 2e57e6197d

View File

@ -863,8 +863,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
TransactionResultHandler resultHandler, // TODO (woodser): transaction not needed with result handler TransactionResultHandler resultHandler, // TODO (woodser): transaction not needed with result handler
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
ThreadUtils.execute(() -> { ThreadUtils.execute(() -> {
synchronized (processOffersLock) {
List<String> errorMessages = new ArrayList<String>(); List<String> errorMessages = new ArrayList<String>();
synchronized (processOffersLock) {
List<OpenOffer> openOffers = getOpenOffers(); List<OpenOffer> openOffers = getOpenOffers();
for (OpenOffer pendingOffer : openOffers) { for (OpenOffer pendingOffer : openOffers) {
if (pendingOffer.getState() != OpenOffer.State.PENDING) continue; if (pendingOffer.getState() != OpenOffer.State.PENDING) continue;
@ -887,13 +887,13 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
}); });
HavenoUtils.awaitLatch(latch); HavenoUtils.awaitLatch(latch);
} }
}
requestPersistence(); requestPersistence();
if (errorMessages.isEmpty()) { if (errorMessages.isEmpty()) {
if (resultHandler != null) resultHandler.handleResult(null); if (resultHandler != null) resultHandler.handleResult(null);
} else { } else {
if (errorMessageHandler != null) errorMessageHandler.handleErrorMessage(errorMessages.toString()); if (errorMessageHandler != null) errorMessageHandler.handleErrorMessage(errorMessages.toString());
} }
}
}, THREAD_ID); }, THREAD_ID);
} }