aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic
diff options
context:
space:
mode:
authorDion Ahmetaj <ahmetajd@coned.com>2017-02-02 12:30:33 -0500
committerDion Ahmetaj <Dion Ahmetaj>2017-02-10 18:07:40 -0500
commit2937fdbbbf9219d345ff561a4ecfe25dbdddd247 (patch)
treee2e6a6d619fdd87d1e1d98891f6fd05a707fd74d /src/cryptonote_basic
parentSet background mining started bool to false on bg thread start. If mining::st... (diff)
downloadmonero-2937fdbbbf9219d345ff561a4ecfe25dbdddd247.tar.xz
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.
Diffstat (limited to 'src/cryptonote_basic')
-rw-r--r--src/cryptonote_basic/miner.cpp25
1 files 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;