Browse Source

Bugfix: Implicitly initialise timer_set_now when it is first called

Luke Dashjr 12 years ago
parent
commit
375725300d
4 changed files with 5 additions and 6 deletions
  1. 0 1
      logging.c
  2. 0 2
      miner.c
  3. 5 2
      util.c
  4. 0 1
      util.h

+ 0 - 1
logging.c

@@ -75,7 +75,6 @@ void _applog(int prio, const char *str)
 			struct timeval tv;
 			struct tm tm;
 			
-			bfg_init_time();
 			bfg_gettimeofday(&tv);
 			localtime_r(&tv.tv_sec, &tm);
 			

+ 0 - 2
miner.c

@@ -532,7 +532,6 @@ struct pool *add_pool(void)
 	/* Make sure the pool doesn't think we've been idle since time 0 */
 	pool->tv_idle.tv_sec = ~0UL;
 	
-	bfg_init_time();
 	cgtime(&pool->cgminer_stats.start_tv);
 
 	pool->rpc_proxy = NULL;
@@ -9183,7 +9182,6 @@ int main(int argc, char *argv[])
 #endif
 
 	raise_fd_limits();
-	bfg_init_time();
 	
 	if (opt_benchmark) {
 		struct pool *pool;

+ 5 - 2
util.c

@@ -1164,11 +1164,13 @@ void _now_queryperformancecounter(struct timeval *tv)
 }
 #endif
 
+static void bfg_init_time();
+
 static
 void _now_is_not_set(__maybe_unused struct timeval *tv)
 {
-	// Might be unclean to swap algorithms after getting a timer
-	quit(1, "timer_set_now called before bfg_init_time");
+	bfg_init_time();
+	timer_set_now(tv);
 }
 
 void (*timer_set_now)(struct timeval *tv) = _now_is_not_set;
@@ -1202,6 +1204,7 @@ bool _bfg_try_clock_gettime(clockid_t clk)
 }
 #endif
 
+static
 void bfg_init_time()
 {
 	if (timer_set_now != _now_is_not_set)

+ 0 - 1
util.h

@@ -225,7 +225,6 @@ bool timer_isset(const struct timeval *tvp)
 }
 
 extern void (*timer_set_now)(struct timeval *);
-extern void bfg_init_time();
 #define cgtime(tvp)  timer_set_now(tvp)
 
 #define TIMEVAL_USECS(usecs)  (  \