Skip to content

Commit 03b3599

Browse files
authored
Merge pull request #5278 from stacks-network/bugfix/failure-to-pass-on-neon-data
Do not abort the runloop unless we were not told to exit
2 parents c4dd40e + 30cd8ec commit 03b3599

File tree

1 file changed

+40
-0
lines changed
  • testnet/stacks-node/src/run_loop

1 file changed

+40
-0
lines changed

testnet/stacks-node/src/run_loop/neon.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,26 @@ impl RunLoop {
13141314
//
13151315
// _this will block if the relayer's buffer is full_
13161316
if !node.relayer_sortition_notify() {
1317+
// First check if we were supposed to cleanly exit
1318+
if !globals.keep_running() {
1319+
// The p2p thread relies on the same atomic_bool, it will
1320+
// discontinue its execution after completing its ongoing runloop epoch.
1321+
info!("Terminating p2p process");
1322+
info!("Terminating relayer");
1323+
info!("Terminating chains-coordinator");
1324+
1325+
globals.coord().stop_chains_coordinator();
1326+
coordinator_thread_handle.join().unwrap();
1327+
let peer_network = node.join();
1328+
liveness_thread.join().unwrap();
1329+
1330+
// Data that will be passed to Nakamoto run loop
1331+
// Only gets transfered on clean shutdown of neon run loop
1332+
let data_to_naka = Neon2NakaData::new(globals, peer_network);
1333+
1334+
info!("Exiting stacks-node");
1335+
return Some(data_to_naka);
1336+
}
13171337
// relayer hung up, exit.
13181338
error!("Runloop: Block relayer and miner hung up, exiting.");
13191339
return None;
@@ -1388,6 +1408,26 @@ impl RunLoop {
13881408
}
13891409

13901410
if !node.relayer_issue_tenure(ibd) {
1411+
// First check if we were supposed to cleanly exit
1412+
if !globals.keep_running() {
1413+
// The p2p thread relies on the same atomic_bool, it will
1414+
// discontinue its execution after completing its ongoing runloop epoch.
1415+
info!("Terminating p2p process");
1416+
info!("Terminating relayer");
1417+
info!("Terminating chains-coordinator");
1418+
1419+
globals.coord().stop_chains_coordinator();
1420+
coordinator_thread_handle.join().unwrap();
1421+
let peer_network = node.join();
1422+
liveness_thread.join().unwrap();
1423+
1424+
// Data that will be passed to Nakamoto run loop
1425+
// Only gets transfered on clean shutdown of neon run loop
1426+
let data_to_naka = Neon2NakaData::new(globals, peer_network);
1427+
1428+
info!("Exiting stacks-node");
1429+
return Some(data_to_naka);
1430+
}
13911431
// relayer hung up, exit.
13921432
error!("Runloop: Block relayer and miner hung up, exiting.");
13931433
break None;

0 commit comments

Comments
 (0)