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