From 1a317680d342b494f73f7dc457460814464dbbd1 Mon Sep 17 00:00:00 2001 From: driftluo Date: Wed, 28 Aug 2024 14:40:52 +0800 Subject: [PATCH] fix: fix atomic ordering in multi-thread --- tx-pool/src/service.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tx-pool/src/service.rs b/tx-pool/src/service.rs index 83621e465e..c4e9e4e0d5 100644 --- a/tx-pool/src/service.rs +++ b/tx-pool/src/service.rs @@ -177,13 +177,13 @@ macro_rules! send_notify { impl TxPoolController { /// Return whether tx-pool service is started pub fn service_started(&self) -> bool { - self.started.load(Ordering::Relaxed) + self.started.load(Ordering::Acquire) } /// Set tx-pool service started, should only used for test #[cfg(feature = "internal")] pub fn set_service_started(&self, v: bool) { - self.started.store(v, Ordering::Relaxed); + self.started.store(v, Ordering::Release); } /// Return reference of tokio runtime handle @@ -658,7 +658,7 @@ impl TxPoolServiceBuilder { } } }); - self.started.store(true, Ordering::Relaxed); + self.started.store(true, Ordering::Release); if let Err(err) = self.tx_pool_controller.load_persisted_data(txs) { error!("Failed to import persistent txs, cause: {}", err); }