mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-03 12:39:35 +00:00
fix windows crasH/instability
This commit is contained in:
parent
6b5afd26fa
commit
19b2eca16d
3 changed files with 28 additions and 14 deletions
|
@ -395,7 +395,9 @@ impl Helper {
|
|||
#[inline(never)]
|
||||
// The P2Pool watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn spawn_p2pool_watchdog(
|
||||
#[allow(clippy::await_holding_lock)]
|
||||
#[tokio::main]
|
||||
async fn spawn_p2pool_watchdog(
|
||||
process: Arc<Mutex<Process>>,
|
||||
gui_api: Arc<Mutex<PubP2poolApi>>,
|
||||
pub_api: Arc<Mutex<PubP2poolApi>>,
|
||||
|
@ -444,7 +446,7 @@ impl Helper {
|
|||
let output_pub = Arc::clone(&lock!(process).output_pub);
|
||||
let gupax_p2pool_api = Arc::clone(&gupax_p2pool_api);
|
||||
let p2pool_api_c = Arc::clone(&gui_api);
|
||||
thread::spawn(move || {
|
||||
tokio::spawn(async move {
|
||||
Self::read_pty_p2pool(
|
||||
output_parse,
|
||||
output_pub,
|
||||
|
@ -726,7 +728,7 @@ impl Helper {
|
|||
lock!(gui_api).tick,
|
||||
sleep
|
||||
);
|
||||
sleep!(sleep);
|
||||
tokio::time::sleep(Duration::from_millis(sleep)).await;
|
||||
} else {
|
||||
debug!(
|
||||
"P2Pool Watchdog | END OF LOOP - Tick: [{}/60] Not sleeping!",
|
||||
|
|
|
@ -456,6 +456,20 @@ impl Helper {
|
|||
lock!(gui_api).node.clone_from(&lock!(img_xmrig).url);
|
||||
// 5. Loop as watchdog
|
||||
info!("XMRig | Entering watchdog mode... woof!");
|
||||
// needs xmrig to be in belownormal priority or else Gupaxx will be in trouble if it does not have enough cpu time.
|
||||
#[cfg(target_os = "windows")]
|
||||
std::process::Command::new("cmd")
|
||||
.args(["/c", "/q", "wmic"])
|
||||
.args([
|
||||
"process",
|
||||
"where",
|
||||
"name='xmrig.exe'",
|
||||
"CALL",
|
||||
"setpriority",
|
||||
"below normal",
|
||||
])
|
||||
.spawn()
|
||||
.expect("failure to execute command wmic");
|
||||
loop {
|
||||
// Set timer
|
||||
let now = Instant::now();
|
||||
|
@ -633,7 +647,7 @@ impl Helper {
|
|||
"XMRig Watchdog | END OF LOOP - Sleeping for [{}]ms...",
|
||||
sleep
|
||||
);
|
||||
sleep!(sleep);
|
||||
tokio::time::sleep(Duration::from_millis(sleep)).await;
|
||||
} else {
|
||||
debug!("XMRig Watchdog | END OF LOOP - Not sleeping!");
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ impl Helper {
|
|||
|
||||
info!("XvB | spawn watchdog");
|
||||
thread::spawn(enc!((state_xvb, state_p2pool, state_xmrig) move || {
|
||||
// thread priority, else there are issue on windows but it is also good for other OS
|
||||
Self::spawn_xvb_watchdog(
|
||||
&gui_api,
|
||||
&pub_api,
|
||||
|
@ -218,18 +219,15 @@ impl Helper {
|
|||
info!("XvB Watchdog | Signal has stopped the loop");
|
||||
break;
|
||||
}
|
||||
let handle_algo_c = lock!(handle_algo);
|
||||
let is_algo_started_once = handle_algo_c.is_some();
|
||||
let is_algo_finished = handle_algo_c
|
||||
// let handle_algo_c = lock!(handle_algo);
|
||||
let is_algo_started_once = lock!(handle_algo).is_some();
|
||||
let is_algo_finished = lock!(handle_algo)
|
||||
.as_ref()
|
||||
.is_some_and(|algo| algo.is_finished());
|
||||
let handle_request_c = lock!(handle_request);
|
||||
let is_request_finished = handle_request_c
|
||||
let is_request_finished = lock!(handle_request)
|
||||
.as_ref()
|
||||
.is_some_and(|request: &JoinHandle<()>| request.is_finished())
|
||||
|| handle_request_c.is_none();
|
||||
drop(handle_algo_c);
|
||||
drop(handle_request_c);
|
||||
|| lock!(handle_request).is_none();
|
||||
// Send an HTTP API request only if one minute is passed since the last request or if first loop or if algorithm need to retry or if request is finished and algo is finished or almost finished (only public and private stats). We make sure public and private stats are refreshed before doing another run of the algo.
|
||||
// We make sure algo or request are not rerun when they are not over.
|
||||
// in the case of quick refresh before new run of algo, make sure it doesn't happen multiple times.
|
||||
|
@ -353,7 +351,7 @@ impl Helper {
|
|||
if elapsed < 999 {
|
||||
let sleep = (999 - elapsed) as u64;
|
||||
debug!("XvB Watchdog | END OF LOOP - Sleeping for [{}]s...", sleep);
|
||||
std::thread::sleep(std::time::Duration::from_millis(sleep))
|
||||
tokio::time::sleep(Duration::from_millis(sleep)).await;
|
||||
} else {
|
||||
debug!("XMRig Watchdog | END OF LOOP - Not sleeping!");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue