Skip to content

Commit

Permalink
Remove deprecated mark_as_success and use new disarm (#4751)
Browse files Browse the repository at this point in the history
  • Loading branch information
octol authored Aug 13, 2024
1 parent da8e513 commit cb4b040
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion clients/native/src/websocket/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl Handler {
) {
// We don't want a crash in the connection handler to trigger a shutdown of the whole
// process.
task_client.mark_as_success();
task_client.disarm();

let ws_stream = match accept_async(socket).await {
Ok(ws_stream) => ws_stream,
Expand Down
4 changes: 2 additions & 2 deletions common/client-core/src/client/base_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ where
Err(ClientCoreError::CustomGatewaySelectionExpected)
} else {
// and make sure to invalidate the task client so we wouldn't cause premature shutdown
shutdown.mark_as_success();
shutdown.disarm();
custom_gateway_transceiver.set_packet_router(packet_router)?;
Ok(custom_gateway_transceiver)
};
Expand Down Expand Up @@ -562,7 +562,7 @@ where
if topology_config.disable_refreshing {
// if we're not spawning the refresher, don't cause shutdown immediately
info!("The topology refesher is not going to be started");
shutdown.mark_as_success();
shutdown.disarm();
} else {
// don't spawn the refresher if we don't want to be refreshing the topology.
// only use the initial values obtained
Expand Down
4 changes: 2 additions & 2 deletions common/client-libs/gateway-client/src/packet_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl PacketRouter {
Ok(())
}

pub fn mark_as_success(&mut self) {
self.shutdown.mark_as_success();
pub fn disarm(&mut self) {
self.shutdown.disarm();
}
}

Expand Down
4 changes: 2 additions & 2 deletions common/client-libs/gateway-client/src/socket_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ impl PartiallyDelegatedRouter {
let return_res = match ret {
Err(err) => self.stream_return.send(Err(err)),
Ok(_) => {
self.packet_router.mark_as_success();
task_client.mark_as_success();
self.packet_router.disarm();
task_client.disarm();
self.stream_return.send(Ok(split_stream))
}
};
Expand Down
2 changes: 1 addition & 1 deletion common/mixnode-common/src/verloc/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl PacketListener {
// cloning the arc as each accepted socket is handled in separate task
let connection_handler = Arc::clone(&self.connection_handler);
let mut handler_shutdown_listener = self.shutdown.clone();
handler_shutdown_listener.mark_as_success();
handler_shutdown_listener.disarm();

tokio::select! {
socket = listener.accept() => {
Expand Down
2 changes: 1 addition & 1 deletion common/mixnode-common/src/verloc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl VerlocMeasurer {
}

let mut shutdown_listener = self.shutdown_listener.clone().named("VerlocMeasurement");
shutdown_listener.mark_as_success();
shutdown_listener.disarm();

for chunk in nodes_to_test.chunks(self.config.tested_nodes_batch_size) {
let mut chunk_results = Vec::with_capacity(chunk.len());
Expand Down
2 changes: 1 addition & 1 deletion common/mixnode-common/src/verloc/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl PacketSender {
tested_node: TestedNode,
) -> Result<VerlocMeasurement, RttError> {
let mut shutdown_listener = self.shutdown_listener.fork(tested_node.address.to_string());
shutdown_listener.mark_as_success();
shutdown_listener.disarm();

let mut conn = match tokio::time::timeout(
self.connection_timeout,
Expand Down
4 changes: 2 additions & 2 deletions common/socks5-client-core/src/socks/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl SocksClient {
packet_type: Option<PacketType>,
) -> Self {
// If this task fails and exits, we don't want to send shutdown signal
shutdown_listener.mark_as_success();
shutdown_listener.disarm();

let connection_id = Self::generate_random();

Expand Down Expand Up @@ -294,7 +294,7 @@ impl SocksClient {
.shutdown()
.await
.map_err(|source| SocksProxyError::SocketShutdownFailure { source })?;
self.shutdown_listener.mark_as_success();
self.shutdown_listener.disarm();
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion common/socks5/proxy-helpers/src/proxy_runner/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,6 @@ where
trace!("{} - inbound closed", connection_id);
shutdown_notify.notify_one();

shutdown_listener.mark_as_success();
shutdown_listener.disarm();
reader
}
2 changes: 1 addition & 1 deletion common/socks5/proxy-helpers/src/proxy_runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ where
}

pub fn into_inner(mut self) -> (TcpStream, ConnectionReceiver) {
self.shutdown_listener.mark_as_success();
self.shutdown_listener.disarm();
(
self.socket.take().unwrap(),
self.mix_receiver.take().unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion common/socks5/proxy-helpers/src/proxy_runner/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ pub(super) async fn run_outbound(
trace!("{} - outbound closed", connection_id);
shutdown_notify.notify_one();

shutdown_listener.mark_as_success();
shutdown_listener.disarm();
(writer, mix_receiver)
}
6 changes: 1 addition & 5 deletions common/task/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,8 @@ impl TaskClient {
// This listener should to *not* notify the ShutdownNotifier to shutdown when dropped. For
// example when we clone the listener for a task handling connections, we often want to drop
// without signal failure.
pub fn mark_as_success(&mut self) {
self.mode.set_should_not_signal_on_drop();
}

pub fn disarm(&mut self) {
self.mark_as_success();
self.mode.set_should_not_signal_on_drop();
}

pub fn send_we_stopped(&mut self, err: SentError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub(crate) async fn handle_connection<R, S, St>(
St: Storage + Clone + 'static,
{
// If the connection handler abruptly stops, we shouldn't signal global shutdown
shutdown.mark_as_success();
shutdown.disarm();

match shutdown
.run_future(handle.perform_websocket_handshake())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<St: Storage> ConnectionHandler<St> {
mut shutdown: TaskClient,
) {
debug!("Starting connection handler for {:?}", remote);
shutdown.mark_as_success();
shutdown.disarm();
let mut framed_conn = Framed::new(conn, NymCodec);
while !shutdown.is_shutdown() {
tokio::select! {
Expand Down
2 changes: 1 addition & 1 deletion mixnode/src/node/listener/connection_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl ConnectionHandler {
mut shutdown: TaskClient,
) {
debug!("Starting connection handler for {:?}", remote);
shutdown.mark_as_success();
shutdown.disarm();
let mut framed_conn = Framed::new(conn, NymCodec);
while !shutdown.is_shutdown() {
tokio::select! {
Expand Down
2 changes: 1 addition & 1 deletion service-providers/network-requester/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl NRServiceProvider {
.send(error_msg)
.await
.expect("InputMessageReceiver has stopped receiving!");
shutdown.mark_as_success();
shutdown.disarm();
return;
}

Expand Down

0 comments on commit cb4b040

Please sign in to comment.