mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
shut down acquires trade lock until no delay so other threads can finish
This commit is contained in:
parent
5545bcde38
commit
4cf6992113
@ -1148,9 +1148,15 @@ public abstract class Trade implements Tradable, Model {
|
||||
public void onShutDownStarted() {
|
||||
isShutDownStarted = true;
|
||||
if (wallet != null) log.info("{} {} preparing for shut down", getClass().getSimpleName(), getId());
|
||||
synchronized (this) {
|
||||
synchronized (walletLock) {
|
||||
stopPolling(); // allow locks to release before stopping
|
||||
|
||||
// allow other threads to finish processing by acquiring trade locks until there's no delay
|
||||
int maxAttempts = 10;
|
||||
for (int i = 0; i < maxAttempts; i++) {
|
||||
long startTimeMs = System.currentTimeMillis();
|
||||
synchronized (this) {
|
||||
synchronized (walletLock) {
|
||||
if (System.currentTimeMillis() - startTimeMs <= 10 || isShutDown) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user