Browse Source

Only display as many device rows as the maximum live existed at any time.

Con Kolivas 12 years ago
parent
commit
cd9ff7f6b8
3 changed files with 14 additions and 1 deletions
  1. 12 1
      cgminer.c
  2. 1 0
      miner.h
  3. 1 0
      usbutils.c

+ 12 - 1
cgminer.c

@@ -115,6 +115,8 @@ static int opt_devs_enabled;
 static bool opt_display_devs;
 static bool opt_display_devs;
 static bool opt_removedisabled;
 static bool opt_removedisabled;
 int total_devices;
 int total_devices;
+int zombie_devs;
+static int most_devices;
 struct cgpu_info **devices;
 struct cgpu_info **devices;
 bool have_opencl;
 bool have_opencl;
 int mining_threads;
 int mining_threads;
@@ -2219,7 +2221,7 @@ static void switch_logsize(void)
 			logstart = devcursor + 1;
 			logstart = devcursor + 1;
 			logcursor = logstart + 1;
 			logcursor = logstart + 1;
 		} else {
 		} else {
-			logstart = devcursor + total_devices + 1;
+			logstart = devcursor + most_devices + 1;
 			logcursor = logstart + 1;
 			logcursor = logstart + 1;
 		}
 		}
 		unlock_curses();
 		unlock_curses();
@@ -7134,6 +7136,12 @@ struct _cgpu_devid_counter {
 	UT_hash_handle hh;
 	UT_hash_handle hh;
 };
 };
 
 
+static void adjust_mostdevs(void)
+{
+	if (total_devices - zombie_devs > most_devices)
+		most_devices = total_devices - zombie_devs;
+}
+
 bool add_cgpu(struct cgpu_info *cgpu)
 bool add_cgpu(struct cgpu_info *cgpu)
 {
 {
 	static struct _cgpu_devid_counter *devids = NULL;
 	static struct _cgpu_devid_counter *devids = NULL;
@@ -7161,6 +7169,8 @@ bool add_cgpu(struct cgpu_info *cgpu)
 		devices[total_devices + new_devices++] = cgpu;
 		devices[total_devices + new_devices++] = cgpu;
 	else
 	else
 		devices[total_devices++] = cgpu;
 		devices[total_devices++] = cgpu;
+
+	adjust_mostdevs();
 	return true;
 	return true;
 }
 }
 
 
@@ -7245,6 +7255,7 @@ static void hotplug_process()
 		applog(LOG_WARNING, "Hotplug: %s added %s %i", cgpu->drv->dname, cgpu->drv->name, cgpu->device_id);
 		applog(LOG_WARNING, "Hotplug: %s added %s %i", cgpu->drv->dname, cgpu->drv->name, cgpu->device_id);
 	}
 	}
 
 
+	adjust_mostdevs();
 	switch_logsize();
 	switch_logsize();
 }
 }
 
 

+ 1 - 0
miner.h

@@ -970,6 +970,7 @@ extern bool opt_scrypt;
 extern double total_secs;
 extern double total_secs;
 extern int mining_threads;
 extern int mining_threads;
 extern int total_devices;
 extern int total_devices;
+extern int zombie_devs;
 extern struct cgpu_info **devices;
 extern struct cgpu_info **devices;
 extern int total_pools;
 extern int total_pools;
 extern struct pool **pools;
 extern struct pool **pools;

+ 1 - 0
usbutils.c

@@ -1363,6 +1363,7 @@ static void release_cgpu(struct cgpu_info *cgpu)
 	if (cgpu->usbinfo.nodev)
 	if (cgpu->usbinfo.nodev)
 		return;
 		return;
 
 
+	zombie_devs++;
 	total_count--;
 	total_count--;
 	drv_count[cgpu->drv->drv_id].count--;
 	drv_count[cgpu->drv->drv_id].count--;