shutting down TorNetworkNode invokes callback handler if already complete

This commit is contained in:
woodser 2023-07-26 09:26:06 -04:00
parent c39c5cf387
commit c548fdaf29
6 changed files with 26 additions and 18 deletions

View file

@ -334,3 +334,10 @@ user3-desktop-stagenet:
--appName=haveno-XMR_STAGENET_user3 \ --appName=haveno-XMR_STAGENET_user3 \
--apiPassword=apitest \ --apiPassword=apitest \
--apiPort=3203 --apiPort=3203
# Mainnet network
monerod:
./.localnet/monerod \
--bootstrap-daemon-address auto \
--rpc-access-control-origins http://localhost:8080 \

View file

@ -1137,7 +1137,7 @@ public abstract class Trade implements Tradable, Model {
} }
public void shutDown() { public void shutDown() {
if (wallet != null) log.info("{} {} shutting down", getClass().getSimpleName(), getId()); if (!isPayoutUnlocked()) log.info("{} {} shutting down", getClass().getSimpleName(), getId());
synchronized (this) { synchronized (this) {
isInitialized = false; isInitialized = false;
isShutDown = true; isShutDown = true;

View file

@ -322,10 +322,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
private void closeAllTrades() { private void closeAllTrades() {
// collect trades to shutdown // collect trades to shutdown
Set<Trade> trades = new HashSet<Trade>(); List<Trade> trades = getAllTrades();
trades.addAll(tradableList.getList());
trades.addAll(closedTradableManager.getClosedTrades());
trades.addAll(failedTradesManager.getObservableList());
// shut down trades in parallel // shut down trades in parallel
Set<Runnable> tasks = new HashSet<Runnable>(); Set<Runnable> tasks = new HashSet<Runnable>();

View file

@ -85,7 +85,6 @@ public final class DepositsConfirmedMessage extends TradeMailboxMessage {
public String toString() { public String toString() {
return "DepositsConfirmedMessage {" + return "DepositsConfirmedMessage {" +
"\n senderNodeAddress=" + senderNodeAddress + "\n senderNodeAddress=" + senderNodeAddress +
",\n pubKeyRing=" + pubKeyRing +
",\n sellerPaymentAccountKey=" + Utilities.bytesAsHexString(sellerPaymentAccountKey) + ",\n sellerPaymentAccountKey=" + Utilities.bytesAsHexString(sellerPaymentAccountKey) +
",\n updatedMultisigHex=" + (updatedMultisigHex == null ? null : updatedMultisigHex.substring(0, Math.max(updatedMultisigHex.length(), 1000))) + ",\n updatedMultisigHex=" + (updatedMultisigHex == null ? null : updatedMultisigHex.substring(0, Math.max(updatedMultisigHex.length(), 1000))) +
"\n} " + super.toString(); "\n} " + super.toString();

View file

@ -45,13 +45,13 @@ Follow [instructions](https://github.com/haveno-dex/haveno-ts#run-tests) to run
## Release portable Monero binaries for each platform ## Release portable Monero binaries for each platform
1. Update the release-v0.18 branch on Haveno's [monero repo](https://github.com/haveno-dex/monero) to the latest release from upstream + any customizations (e.g. a commit to speed up testnet hardforks for local development (b509b1)). 1. Update the release-v0.18 branch on Haveno's [monero repo](https://github.com/haveno-dex/monero) to the latest release from upstream + any customizations (e.g. a commit to speed up testnet hardforks for local development).
2. git tag testing12 && git push haveno testing12 2. `git tag <tag> && git push haveno <tag>`
3. Follow instructions to [build portable binaries for each platform](#build-portable-monero-binaries-for-each-platform). 3. Follow instructions to [build portable binaries for each platform](#build-portable-monero-binaries-for-each-platform).
4. Publish a new release at https://github.com/haveno-dex/monero/releases with the updated binaries and hashes. 4. Publish a new release at https://github.com/haveno-dex/monero/releases with the updated binaries and hashes.
5. Update the paths and hashes in build.gradle and PR. 5. Update the paths and hashes in build.gradle and PR.
## Build portable Monero binaries for each platform ### Build portable Monero binaries for each platform
Based on these instructions: https://github.com/monero-project/monero#cross-compiling Based on these instructions: https://github.com/monero-project/monero#cross-compiling
@ -60,8 +60,8 @@ Based on these instructions: https://github.com/monero-project/monero#cross-comp
3. `sudo apt install cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev libtinfo5 autoconf libtool libtool-bin gperf` 3. `sudo apt install cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev libtinfo5 autoconf libtool libtool-bin gperf`
4. `git clone https://github.com/haveno-dex/monero.git` 4. `git clone https://github.com/haveno-dex/monero.git`
5. `cd ./monero (or rename this folder)` 5. `cd ./monero (or rename this folder)`
6. `git submodule update --init --force` 6. `git fetch origin && git reset --hard origin/release-v0.18`
7. `git submodule update --init --force`
> Note: > Note:
> If you get the prompt "Reversed (or previously applied) patch detected! Assume -R? [n]" then confirm 'y'. > If you get the prompt "Reversed (or previously applied) patch detected! Assume -R? [n]" then confirm 'y'.

View file

@ -58,6 +58,7 @@ public class TorNetworkNode extends NetworkNode {
private boolean streamIsolation; private boolean streamIsolation;
private Socks5Proxy socksProxy; private Socks5Proxy socksProxy;
private boolean shutDownInProgress; private boolean shutDownInProgress;
private boolean shutDownComplete;
private final ExecutorService executor; private final ExecutorService executor;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -121,17 +122,21 @@ public class TorNetworkNode extends NetworkNode {
public void shutDown(@Nullable Runnable shutDownCompleteHandler) { public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
log.info("TorNetworkNode shutdown started"); log.info("TorNetworkNode shutdown started");
if (shutDownComplete) {
log.info("TorNetworkNode shutdown already completed");
if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
return;
}
if (shutDownInProgress) { if (shutDownInProgress) {
log.warn("We got shutDown already called"); log.warn("Ignoring request to shut down because shut down is in progress");
return; return;
} }
shutDownInProgress = true; shutDownInProgress = true;
shutDownTimeoutTimer = UserThread.runAfter(() -> { shutDownTimeoutTimer = UserThread.runAfter(() -> {
log.error("A timeout occurred at shutDown"); log.error("A timeout occurred at shutDown");
if (shutDownCompleteHandler != null) shutDownComplete = true;
shutDownCompleteHandler.run(); if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
executor.shutdownNow(); executor.shutdownNow();
}, SHUT_DOWN_TIMEOUT); }, SHUT_DOWN_TIMEOUT);
@ -148,8 +153,8 @@ public class TorNetworkNode extends NetworkNode {
log.error("Shutdown torNetworkNode failed with exception", e); log.error("Shutdown torNetworkNode failed with exception", e);
} finally { } finally {
shutDownTimeoutTimer.stop(); shutDownTimeoutTimer.stop();
if (shutDownCompleteHandler != null) shutDownComplete = true;
shutDownCompleteHandler.run(); if (shutDownCompleteHandler != null) shutDownCompleteHandler.run();
} }
}); });
} }