mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-03-01 04:50:15 +00:00
fix: potential deadlock
This commit is contained in:
parent
34f694c8a3
commit
3b3d6f1d46
3 changed files with 6 additions and 6 deletions
src/helper
|
@ -833,13 +833,14 @@ impl PubP2poolApi {
|
||||||
process: &mut Process,
|
process: &mut Process,
|
||||||
) {
|
) {
|
||||||
// 1. Take the process's current output buffer and combine it with Pub (if not empty)
|
// 1. Take the process's current output buffer and combine it with Pub (if not empty)
|
||||||
let mut output_parse = output_parse.lock().unwrap();
|
|
||||||
let mut output_pub = output_pub.lock().unwrap();
|
let mut output_pub = output_pub.lock().unwrap();
|
||||||
if !output_pub.is_empty() {
|
if !output_pub.is_empty() {
|
||||||
public.output.push_str(&std::mem::take(&mut *output_pub));
|
public.output.push_str(&std::mem::take(&mut *output_pub));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop(output_pub);
|
||||||
// 2. Parse the full STDOUT
|
// 2. Parse the full STDOUT
|
||||||
|
let mut output_parse = output_parse.lock().unwrap();
|
||||||
let (payouts_new, xmr_new) = Self::calc_payouts_and_xmr(&output_parse);
|
let (payouts_new, xmr_new) = Self::calc_payouts_and_xmr(&output_parse);
|
||||||
// Check for "SYNCHRONIZED" only if we aren't already.
|
// Check for "SYNCHRONIZED" only if we aren't already.
|
||||||
if process.state == ProcessState::Syncing {
|
if process.state == ProcessState::Syncing {
|
||||||
|
@ -866,7 +867,6 @@ impl PubP2poolApi {
|
||||||
|
|
||||||
// 3. Throw away [output_parse]
|
// 3. Throw away [output_parse]
|
||||||
output_parse.clear();
|
output_parse.clear();
|
||||||
drop(output_pub);
|
|
||||||
drop(output_parse);
|
drop(output_parse);
|
||||||
// 4. Add to current values
|
// 4. Add to current values
|
||||||
let (payouts, xmr) = (public.payouts + payouts_new, public.xmr + xmr_new);
|
let (payouts, xmr) = (public.payouts + payouts_new, public.xmr + xmr_new);
|
||||||
|
|
|
@ -746,7 +746,6 @@ impl PubXmrigApi {
|
||||||
process: &mut Process,
|
process: &mut Process,
|
||||||
) {
|
) {
|
||||||
// 1. Take the process's current output buffer and combine it with Pub (if not empty)
|
// 1. Take the process's current output buffer and combine it with Pub (if not empty)
|
||||||
let mut output_parse = output_parse.lock().unwrap();
|
|
||||||
let mut output_pub = output_pub.lock().unwrap();
|
let mut output_pub = output_pub.lock().unwrap();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -756,7 +755,9 @@ impl PubXmrigApi {
|
||||||
// Update uptime
|
// Update uptime
|
||||||
public.uptime = elapsed;
|
public.uptime = elapsed;
|
||||||
}
|
}
|
||||||
|
drop(output_pub);
|
||||||
|
|
||||||
|
let mut output_parse = output_parse.lock().unwrap();
|
||||||
// 2. Check for "new job"/"no active...".
|
// 2. Check for "new job"/"no active...".
|
||||||
if XMRIG_REGEX.new_job.is_match(&output_parse) {
|
if XMRIG_REGEX.new_job.is_match(&output_parse) {
|
||||||
process.state = ProcessState::Alive;
|
process.state = ProcessState::Alive;
|
||||||
|
@ -771,7 +772,6 @@ impl PubXmrigApi {
|
||||||
|
|
||||||
// 3. Throw away [output_parse]
|
// 3. Throw away [output_parse]
|
||||||
output_parse.clear();
|
output_parse.clear();
|
||||||
drop(output_pub);
|
|
||||||
drop(output_parse);
|
drop(output_parse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -504,7 +504,6 @@ impl PubXmrigProxyApi {
|
||||||
process: &mut Process,
|
process: &mut Process,
|
||||||
) {
|
) {
|
||||||
// 1. Take the process's current output buffer and combine it with Pub (if not empty)
|
// 1. Take the process's current output buffer and combine it with Pub (if not empty)
|
||||||
let mut output_parse = output_parse.lock().unwrap();
|
|
||||||
let mut output_pub = output_pub.lock().unwrap();
|
let mut output_pub = output_pub.lock().unwrap();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -515,6 +514,8 @@ impl PubXmrigProxyApi {
|
||||||
public.uptime = elapsed;
|
public.uptime = elapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop(output_pub);
|
||||||
|
let mut output_parse = output_parse.lock().unwrap();
|
||||||
// 2. Check for "new job"/"no active...".
|
// 2. Check for "new job"/"no active...".
|
||||||
if XMRIG_REGEX.new_job.is_match(&output_parse)
|
if XMRIG_REGEX.new_job.is_match(&output_parse)
|
||||||
|| XMRIG_REGEX.valid_conn.is_match(&output_parse)
|
|| XMRIG_REGEX.valid_conn.is_match(&output_parse)
|
||||||
|
@ -533,7 +534,6 @@ impl PubXmrigProxyApi {
|
||||||
}
|
}
|
||||||
// 3. Throw away [output_parse]
|
// 3. Throw away [output_parse]
|
||||||
output_parse.clear();
|
output_parse.clear();
|
||||||
drop(output_pub);
|
|
||||||
drop(output_parse);
|
drop(output_parse);
|
||||||
}
|
}
|
||||||
// same method as PubXmrigApi, why not make a trait ?
|
// same method as PubXmrigApi, why not make a trait ?
|
||||||
|
|
Loading…
Reference in a new issue