set poll in progress from single caller at a time

This commit is contained in:
woodser 2024-10-16 07:19:51 -04:00
parent 7094dfcc09
commit 329fa1c39a
2 changed files with 25 additions and 5 deletions

View file

@ -2500,10 +2500,18 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
} }
private void doPollWallet() { private void doPollWallet() {
// skip if shut down started
if (isShutDownStarted) return; if (isShutDownStarted) return;
// set poll in progress
boolean pollInProgressSet = false;
synchronized (pollLock) { synchronized (pollLock) {
if (!pollInProgress) pollInProgressSet = true;
pollInProgress = true; pollInProgress = true;
} }
// poll wallet
try { try {
// skip if payout unlocked // skip if payout unlocked
@ -2628,8 +2636,10 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
} }
} }
} finally { } finally {
synchronized (pollLock) { if (pollInProgressSet) {
pollInProgress = false; synchronized (pollLock) {
pollInProgress = false;
}
} }
requestSaveWallet(); requestSaveWallet();
} }

View file

@ -1837,10 +1837,18 @@ public class XmrWalletService extends XmrWalletBase {
} }
private void doPollWallet(boolean updateTxs) { private void doPollWallet(boolean updateTxs) {
// skip if shut down started
if (isShutDownStarted) return;
// set poll in progress
boolean pollInProgressSet = false;
synchronized (pollLock) { synchronized (pollLock) {
if (!pollInProgress) pollInProgressSet = true;
pollInProgress = true; pollInProgress = true;
} }
if (isShutDownStarted) return;
// poll wallet
try { try {
// skip if daemon not synced // skip if daemon not synced
@ -1903,8 +1911,10 @@ public class XmrWalletService extends XmrWalletBase {
//e.printStackTrace(); //e.printStackTrace();
} }
} finally { } finally {
synchronized (pollLock) { if (pollInProgressSet) {
pollInProgress = false; synchronized (pollLock) {
pollInProgress = false;
}
} }
// cache wallet info last // cache wallet info last