Merge remote-tracking branch 'origin/release/v1.1.2' into release/v1.1.3

This commit is contained in:
Jon Häggblad
2022-11-29 12:57:48 +01:00
4 changed files with 21 additions and 8 deletions
+1 -2
View File
@@ -38,8 +38,7 @@ use log::*;
use nymsphinx::addressing::clients::Recipient;
use nymsphinx::addressing::nodes::NodeIdentity;
use tap::TapFallible;
use task::signal::wait_for_signal_and_error;
use task::{ShutdownListener, ShutdownNotifier};
use task::{wait_for_signal_and_error, ShutdownListener, ShutdownNotifier};
pub mod config;
+1 -1
View File
@@ -5,4 +5,4 @@ pub mod shutdown;
pub mod signal;
pub use shutdown::{ShutdownListener, ShutdownNotifier};
pub use signal::wait_for_signal;
pub use signal::{wait_for_signal, wait_for_signal_and_error};
+18 -4
View File
@@ -1,3 +1,5 @@
use crate::{shutdown::SentError, ShutdownNotifier};
#[cfg(unix)]
pub async fn wait_for_signal() {
use tokio::signal::unix::{signal, SignalKind};
@@ -17,10 +19,17 @@ pub async fn wait_for_signal() {
}
}
#[cfg(not(unix))]
pub async fn wait_for_signal() {
tokio::select! {
_ = tokio::signal::ctrl_c() => {
log::info!("Received SIGINT");
},
}
}
#[cfg(unix)]
pub async fn wait_for_signal_and_error(
shutdown: &mut crate::ShutdownNotifier,
) -> Result<(), crate::shutdown::SentError> {
pub async fn wait_for_signal_and_error(shutdown: &mut ShutdownNotifier) -> Result<(), SentError> {
use tokio::signal::unix::{signal, SignalKind};
let mut sigterm = signal(SignalKind::terminate()).expect("Failed to setup SIGTERM channel");
@@ -47,10 +56,15 @@ pub async fn wait_for_signal_and_error(
}
#[cfg(not(unix))]
pub async fn wait_for_signal() {
pub async fn wait_for_signal_and_error(shutdown: &mut ShutdownNotifier) -> Result<(), SentError> {
tokio::select! {
_ = tokio::signal::ctrl_c() => {
log::info!("Received SIGINT");
Ok(())
},
Some(msg) = shutdown.wait_for_error() => {
log::info!("Task error: {:?}", msg);
Err(msg)
}
}
}
+1 -1
View File
@@ -113,7 +113,7 @@ pub fn start_disconnect_listener(
"socks5-event",
Payload {
title: "SOCKS5 error".into(),
message: "SOCKS5 stopped abruptly".into(),
message: "SOCKS5 stopped abruptly. Please try reconnecting.".into(),
},
)
.unwrap();