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