mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 07:15:54 -04:00
remove trade lock while shutting down trade thread
This commit is contained in:
parent
7243d7fa38
commit
ad38e3b80c
@ -1607,13 +1607,11 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||
}
|
||||
|
||||
// shut down trade threads
|
||||
synchronized (getLock()) {
|
||||
isInitialized = false;
|
||||
isShutDown = true;
|
||||
List<Runnable> shutDownThreads = new ArrayList<>();
|
||||
shutDownThreads.add(() -> ThreadUtils.shutDown(getId()));
|
||||
ThreadUtils.awaitTasks(shutDownThreads);
|
||||
}
|
||||
isInitialized = false;
|
||||
isShutDown = true;
|
||||
List<Runnable> shutDownThreads = new ArrayList<>();
|
||||
shutDownThreads.add(() -> ThreadUtils.shutDown(getId()));
|
||||
ThreadUtils.awaitTasks(shutDownThreads);
|
||||
|
||||
// save and close
|
||||
if (wallet != null) {
|
||||
@ -2513,7 +2511,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||
try {
|
||||
syncWallet(pollWallet);
|
||||
} catch (Exception e) {
|
||||
if (!isShutDown && walletExists()) {
|
||||
if (!isShutDownStarted && walletExists()) {
|
||||
log.warn("Error syncing trade wallet for {} {}: {}", getClass().getSimpleName(), getId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -62,28 +62,28 @@ public class BuyerAsMakerProtocol extends BuyerProtocol implements MakerProtocol
|
||||
ErrorMessageHandler errorMessageHandler) {
|
||||
log.info(TradeProtocol.LOG_HIGHLIGHT + "handleInitTradeRequest() for {} {} from {}", trade.getClass().getSimpleName(), trade.getShortId(), peer);
|
||||
ThreadUtils.execute(() -> {
|
||||
synchronized (trade.getLock()) {
|
||||
latchTrade();
|
||||
this.errorMessageHandler = errorMessageHandler;
|
||||
expect(phase(Trade.Phase.INIT)
|
||||
.with(message)
|
||||
.from(peer))
|
||||
.setup(tasks(
|
||||
ApplyFilter.class,
|
||||
ProcessInitTradeRequest.class,
|
||||
MakerSendInitTradeRequestToArbitrator.class)
|
||||
.using(new TradeTaskRunner(trade,
|
||||
() -> {
|
||||
startTimeout();
|
||||
handleTaskRunnerSuccess(peer, message);
|
||||
},
|
||||
errorMessage -> {
|
||||
handleTaskRunnerFault(peer, message, errorMessage);
|
||||
}))
|
||||
.withTimeout(TRADE_STEP_TIMEOUT_SECONDS))
|
||||
.executeTasks(true);
|
||||
awaitTradeLatch();
|
||||
}
|
||||
}, trade.getId());
|
||||
synchronized (trade.getLock()) {
|
||||
latchTrade();
|
||||
this.errorMessageHandler = errorMessageHandler;
|
||||
expect(phase(Trade.Phase.INIT)
|
||||
.with(message)
|
||||
.from(peer))
|
||||
.setup(tasks(
|
||||
ApplyFilter.class,
|
||||
ProcessInitTradeRequest.class,
|
||||
MakerSendInitTradeRequestToArbitrator.class)
|
||||
.using(new TradeTaskRunner(trade,
|
||||
() -> {
|
||||
startTimeout();
|
||||
handleTaskRunnerSuccess(peer, message);
|
||||
},
|
||||
errorMessage -> {
|
||||
handleTaskRunnerFault(peer, message, errorMessage);
|
||||
}))
|
||||
.withTimeout(TRADE_STEP_TIMEOUT_SECONDS))
|
||||
.executeTasks(true);
|
||||
awaitTradeLatch();
|
||||
}
|
||||
}, trade.getId());
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +110,10 @@ public abstract class XmrWalletBase {
|
||||
try {
|
||||
height = wallet.getHeight(); // can get read timeout while syncing
|
||||
} catch (Exception e) {
|
||||
log.warn("Error getting wallet height while syncing with progress: " + e.getMessage());
|
||||
if (wallet != null && !isShutDownStarted) log.warn(ExceptionUtils.getStackTrace(e));
|
||||
if (wallet != null && !isShutDownStarted) {
|
||||
log.warn("Error getting wallet height while syncing with progress: " + e.getMessage());
|
||||
log.warn(ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
|
||||
// stop polling and release latch
|
||||
syncProgressError = e;
|
||||
|
Loading…
x
Reference in New Issue
Block a user