From 2937fdbbbf9219d345ff561a4ecfe25dbdddd247 Mon Sep 17 00:00:00 2001 From: Dion Ahmetaj Date: Thu, 2 Feb 2017 12:30:33 -0500 Subject: [PATCH] Moved setting of previous process times to block where background mining is started, and added an explicit sleep in that block to wait for some mining to occur. --- src/cryptonote_basic/miner.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index d424dd5e7..9ae56be38 100644 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -578,19 +578,6 @@ namespace cryptonote if( m_is_background_mining_started ) { // figure out if we need to stop, and monitor mining usage - - // previous is uninitialized - if(previous_process_time == 0) - { - // get some starting data .. - if(!get_system_times(prev_total_time, prev_idle_time)) - LOG_ERROR(__func__ << " : get_system_times call failed"); - - if(!get_process_time(previous_process_time)) - LOG_ERROR(__func__ << " : get_process_time call failed!"); - - continue; - } // If we get here, then previous values are initialized. // Let's get some current data for comparison. @@ -659,7 +646,17 @@ namespace cryptonote { MGINFO(__func__ << " : cpu is " << unsigned(idle_percentage) << "% idle, idle threshold is " << unsigned(get_idle_threshold()) << "\%, ac power : " << on_ac_power << ", background mining started, good luck!"); m_is_background_mining_started = true; - m_is_background_mining_started_cond.notify_all(); + m_is_background_mining_started_cond.notify_all(); + + // Wait for a little mining to happen .. + boost::this_thread::sleep_for(boost::chrono::seconds( 1 )); + + // Starting data ... + if(!get_process_time(previous_process_time)) + { + m_is_background_mining_started = false; + LOG_ERROR(__func__ << " : get_process_time call failed!"); + } } prev_total_time = current_total_time;