mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
skip trade protocol message processing if shutting down
This commit is contained in:
parent
e4e8f5d311
commit
19d3e2853d
@ -1271,6 +1271,8 @@ public abstract class Trade implements Tradable, Model {
|
||||
|
||||
// shut down trade threads
|
||||
synchronized (this) {
|
||||
isInitialized = false;
|
||||
isShutDown = true;
|
||||
List<Runnable> shutDownThreads = new ArrayList<>();
|
||||
shutDownThreads.add(() -> ThreadUtils.shutDown(getId()));
|
||||
shutDownThreads.add(() -> ThreadUtils.shutDown(getConnectionChangedThreadId()));
|
||||
@ -1305,8 +1307,6 @@ public abstract class Trade implements Tradable, Model {
|
||||
}
|
||||
|
||||
// de-initialize
|
||||
isInitialized = false;
|
||||
isShutDown = true;
|
||||
if (idlePayoutSyncer != null) {
|
||||
xmrWalletService.removeWalletListener(idlePayoutSyncer);
|
||||
idlePayoutSyncer = null;
|
||||
|
@ -469,8 +469,10 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
|
||||
public void handle(DepositsConfirmedMessage response, NodeAddress sender) {
|
||||
System.out.println(getClass().getSimpleName() + ".handle(DepositsConfirmedMessage)");
|
||||
if (!trade.isInitialized() || trade.isShutDown()) return;
|
||||
ThreadUtils.execute(() -> {
|
||||
synchronized (trade) {
|
||||
if (!trade.isInitialized() || trade.isShutDown()) return;
|
||||
latchTrade();
|
||||
this.errorMessageHandler = null;
|
||||
expect(new Condition(trade)
|
||||
@ -496,6 +498,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
// received by seller and arbitrator
|
||||
protected void handle(PaymentSentMessage message, NodeAddress peer) {
|
||||
System.out.println(getClass().getSimpleName() + ".handle(PaymentSentMessage)");
|
||||
if (!trade.isInitialized() || trade.isShutDown()) return;
|
||||
if (!(trade instanceof SellerTrade || trade instanceof ArbitratorTrade)) {
|
||||
log.warn("Ignoring PaymentSentMessage since not seller or arbitrator");
|
||||
return;
|
||||
@ -507,6 +510,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
// TODO A better fix would be to add a listener for the wallet sync state and process
|
||||
// the mailbox msg once wallet is ready and trade state set.
|
||||
synchronized (trade) {
|
||||
if (!trade.isInitialized() || trade.isShutDown()) return;
|
||||
if (trade.getPhase().ordinal() >= Trade.Phase.PAYMENT_SENT.ordinal()) {
|
||||
log.warn("Received another PaymentSentMessage which was already processed, ACKing");
|
||||
handleTaskRunnerSuccess(peer, message);
|
||||
@ -548,12 +552,14 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
|
||||
private void handle(PaymentReceivedMessage message, NodeAddress peer, boolean reprocessOnError) {
|
||||
System.out.println(getClass().getSimpleName() + ".handle(PaymentReceivedMessage)");
|
||||
if (!trade.isInitialized() || trade.isShutDown()) return;
|
||||
ThreadUtils.execute(() -> {
|
||||
if (!(trade instanceof BuyerTrade || trade instanceof ArbitratorTrade)) {
|
||||
log.warn("Ignoring PaymentReceivedMessage since not buyer or arbitrator");
|
||||
return;
|
||||
}
|
||||
synchronized (trade) {
|
||||
if (!trade.isInitialized() || trade.isShutDown()) return;
|
||||
latchTrade();
|
||||
Validator.checkTradeId(processModel.getOfferId(), message);
|
||||
processModel.setTradeMessage(message);
|
||||
|
Loading…
Reference in New Issue
Block a user