Only display as many device rows as the maximum live existed at any time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
diff --git a/cgminer.c b/cgminer.c
index b8bd5d6..a27a2c5 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -115,6 +115,8 @@ static int opt_devs_enabled;
static bool opt_display_devs;
static bool opt_removedisabled;
int total_devices;
+int zombie_devs;
+static int most_devices;
struct cgpu_info **devices;
bool have_opencl;
int mining_threads;
@@ -2219,7 +2221,7 @@ static void switch_logsize(void)
logstart = devcursor + 1;
logcursor = logstart + 1;
} else {
- logstart = devcursor + total_devices + 1;
+ logstart = devcursor + most_devices + 1;
logcursor = logstart + 1;
}
unlock_curses();
@@ -7134,6 +7136,12 @@ struct _cgpu_devid_counter {
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)
{
static struct _cgpu_devid_counter *devids = NULL;
@@ -7161,6 +7169,8 @@ bool add_cgpu(struct cgpu_info *cgpu)
devices[total_devices + new_devices++] = cgpu;
else
devices[total_devices++] = cgpu;
+
+ adjust_mostdevs();
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);
}
+ adjust_mostdevs();
switch_logsize();
}
diff --git a/miner.h b/miner.h
index 6fc82b8..bcc3c03 100644
--- a/miner.h
+++ b/miner.h
@@ -970,6 +970,7 @@ extern bool opt_scrypt;
extern double total_secs;
extern int mining_threads;
extern int total_devices;
+extern int zombie_devs;
extern struct cgpu_info **devices;
extern int total_pools;
extern struct pool **pools;
diff --git a/usbutils.c b/usbutils.c
index b226fc6..9fdb1ea 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -1363,6 +1363,7 @@ static void release_cgpu(struct cgpu_info *cgpu)
if (cgpu->usbinfo.nodev)
return;
+ zombie_devs++;
total_count--;
drv_count[cgpu->drv->drv_id].count--;