Browse Source

Merge commit '0c41b1b' into cg_merges_20121210

Luke Dashjr 13 years ago
parent
commit
cade98b1da
2 changed files with 8 additions and 5 deletions
  1. 5 5
      api.c
  2. 3 0
      usbutils.c

+ 5 - 5
api.c

@@ -3365,16 +3365,16 @@ void api(int api_thr_id)
 	bool did;
 	int i;
 
-	mutex_init(&quit_restart_lock);
-
-	pthread_cleanup_push(tidyup, NULL);
-	my_thr_id = api_thr_id;
-
 	if (!opt_api_listen) {
 		applog(LOG_DEBUG, "API not running%s", UNAVAILABLE);
 		return;
 	}
 
+	mutex_init(&quit_restart_lock);
+
+	pthread_cleanup_push(tidyup, NULL);
+	my_thr_id = api_thr_id;
+
 	setup_groups();
 
 	if (opt_api_allow) {

+ 3 - 0
usbutils.c

@@ -1061,6 +1061,9 @@ static void newstats(struct cgpu_info *cgpu)
 void update_usb_stats(__maybe_unused struct cgpu_info *cgpu)
 {
 #if DO_USB_STATS
+	if (cgpu->usbstat < 1)
+		newstats(cgpu);
+
 	// we don't know the device_id until after add_cgpu()
 	usb_stats[cgpu->usbstat - 1].device_id = cgpu->device_id;
 #endif