mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-31 00:44:19 +00:00
fix broken disabled devices when remove-disabled is set
This commit is contained in:
parent
8f53b7c86c
commit
1c2de13498
20
api.c
20
api.c
@ -2507,7 +2507,7 @@ static void notify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe
|
|||||||
{
|
{
|
||||||
struct cgpu_info *cgpu;
|
struct cgpu_info *cgpu;
|
||||||
bool io_open = false;
|
bool io_open = false;
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
if (total_devices == 0) {
|
if (total_devices == 0) {
|
||||||
message(io_data, MSG_NODEVS, 0, NULL, isjson);
|
message(io_data, MSG_NODEVS, 0, NULL, isjson);
|
||||||
@ -2519,9 +2519,10 @@ static void notify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe
|
|||||||
if (isjson)
|
if (isjson)
|
||||||
io_open = io_add(io_data, COMSTR JSON_NOTIFY);
|
io_open = io_add(io_data, COMSTR JSON_NOTIFY);
|
||||||
|
|
||||||
for (i = 0; i < total_devices; i++) {
|
for (i = 0, j = 0; i < total_devices; i++) {
|
||||||
cgpu = get_devices(i);
|
cgpu = get_devices(i);
|
||||||
notifystatus(io_data, i, cgpu, isjson, group);
|
if (!opt_removedisabled || cgpu->deven != DEV_DISABLED)
|
||||||
|
notifystatus(io_data, j++, cgpu, isjson, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isjson && io_open)
|
if (isjson && io_open)
|
||||||
@ -2534,7 +2535,7 @@ static void devdetails(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
|||||||
char buf[TMPBUFSIZ];
|
char buf[TMPBUFSIZ];
|
||||||
bool io_open = false;
|
bool io_open = false;
|
||||||
struct cgpu_info *cgpu;
|
struct cgpu_info *cgpu;
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
if (total_devices == 0) {
|
if (total_devices == 0) {
|
||||||
message(io_data, MSG_NODEVS, 0, NULL, isjson);
|
message(io_data, MSG_NODEVS, 0, NULL, isjson);
|
||||||
@ -2546,10 +2547,12 @@ static void devdetails(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
|||||||
if (isjson)
|
if (isjson)
|
||||||
io_open = io_add(io_data, COMSTR JSON_DEVDETAILS);
|
io_open = io_add(io_data, COMSTR JSON_DEVDETAILS);
|
||||||
|
|
||||||
for (i = 0; i < total_devices; i++) {
|
for (i = 0, j = 0; i < total_devices; i++) {
|
||||||
cgpu = get_devices(i);
|
cgpu = get_devices(i);
|
||||||
|
|
||||||
root = api_add_int(root, "DEVDETAILS", &i, false);
|
if (opt_removedisabled && cgpu->deven == DEV_DISABLED) continue;
|
||||||
|
|
||||||
|
root = api_add_int(root, "DEVDETAILS", &j, false);
|
||||||
root = api_add_string(root, "Name", cgpu->drv->name, false);
|
root = api_add_string(root, "Name", cgpu->drv->name, false);
|
||||||
root = api_add_int(root, "ID", &(cgpu->device_id), false);
|
root = api_add_int(root, "ID", &(cgpu->device_id), false);
|
||||||
root = api_add_string(root, "Driver", cgpu->drv->dname, false);
|
root = api_add_string(root, "Driver", cgpu->drv->dname, false);
|
||||||
@ -2557,8 +2560,9 @@ static void devdetails(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
|||||||
root = api_add_const(root, "Model", cgpu->name ? cgpu->name : BLANK, false);
|
root = api_add_const(root, "Model", cgpu->name ? cgpu->name : BLANK, false);
|
||||||
root = api_add_const(root, "Device Path", cgpu->device_path ? cgpu->device_path : BLANK, false);
|
root = api_add_const(root, "Device Path", cgpu->device_path ? cgpu->device_path : BLANK, false);
|
||||||
|
|
||||||
root = print_data(root, buf, isjson, isjson && (i > 0));
|
root = print_data(root, buf, isjson, isjson && (j > 0));
|
||||||
io_add(io_data, buf);
|
io_add(io_data, buf);
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isjson && io_open)
|
if (isjson && io_open)
|
||||||
@ -2659,7 +2663,7 @@ static void minerstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
|||||||
for (j = 0; j < total_devices; j++) {
|
for (j = 0; j < total_devices; j++) {
|
||||||
cgpu = get_devices(j);
|
cgpu = get_devices(j);
|
||||||
|
|
||||||
if (cgpu && cgpu->drv) {
|
if (cgpu && cgpu->drv && (!opt_removedisabled || cgpu->deven != DEV_DISABLED)) {
|
||||||
if (cgpu->drv->get_api_stats)
|
if (cgpu->drv->get_api_stats)
|
||||||
extra = cgpu->drv->get_api_stats(cgpu);
|
extra = cgpu->drv->get_api_stats(cgpu);
|
||||||
else
|
else
|
||||||
|
48
sgminer.c
48
sgminer.c
@ -203,7 +203,6 @@ int total_devices;
|
|||||||
static int most_devices;
|
static int most_devices;
|
||||||
struct cgpu_info **devices;
|
struct cgpu_info **devices;
|
||||||
int mining_threads;
|
int mining_threads;
|
||||||
static int sgminer_id_count = 0;
|
|
||||||
|
|
||||||
#ifdef HAVE_CURSES
|
#ifdef HAVE_CURSES
|
||||||
bool use_curses = true;
|
bool use_curses = true;
|
||||||
@ -507,7 +506,7 @@ struct cgpu_info *get_devices(int id)
|
|||||||
return cgpu;
|
return cgpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enable_device(struct cgpu_info *cgpu);
|
void enable_device(int i);
|
||||||
|
|
||||||
static void sharelog(const char*disposition, const struct work*work)
|
static void sharelog(const char*disposition, const struct work*work)
|
||||||
{
|
{
|
||||||
@ -5983,21 +5982,15 @@ static void enable_devices(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
//enable/disable devices as needed
|
//enable/disable devices as needed
|
||||||
sgminer_id_count = 0;
|
|
||||||
|
|
||||||
if(opt_devs_enabled)
|
if(opt_devs_enabled)
|
||||||
{
|
{
|
||||||
for (i = 0; i < total_devices; i++)
|
for (i = 0; i < total_devices; i++)
|
||||||
{
|
{
|
||||||
//device should be enabled
|
//device should be enabled
|
||||||
if(devices_enabled[i])
|
if(devices_enabled[i])
|
||||||
enable_device(devices[i]);
|
enable_device(i);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//if option is set to not remove disabled, enable device
|
|
||||||
if(!opt_removedisabled)
|
|
||||||
enable_device(devices[i]);
|
|
||||||
|
|
||||||
//mark as disabled
|
//mark as disabled
|
||||||
devices[i]->deven = DEV_DISABLED;
|
devices[i]->deven = DEV_DISABLED;
|
||||||
}
|
}
|
||||||
@ -6007,7 +6000,7 @@ static void enable_devices(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < total_devices; ++i)
|
for (i = 0; i < total_devices; ++i)
|
||||||
enable_device(devices[i]);
|
enable_device(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6030,11 +6023,7 @@ static void apply_initial_gpu_settings(struct pool *pool)
|
|||||||
|
|
||||||
//assign pool devices if any
|
//assign pool devices if any
|
||||||
if(!empty_string((opt = get_pool_setting(pool->devices, ((!empty_string(default_profile.devices))?default_profile.devices:"all"))))) {
|
if(!empty_string((opt = get_pool_setting(pool->devices, ((!empty_string(default_profile.devices))?default_profile.devices:"all"))))) {
|
||||||
if (opt_removedisabled) {
|
set_devices((char *)opt);
|
||||||
applog(LOG_ERR, "Changing enabled devices is not possible when remove-disabled is set.");
|
|
||||||
} else {
|
|
||||||
set_devices((char *)opt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//lookup gap
|
//lookup gap
|
||||||
@ -6373,11 +6362,7 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
|
|||||||
|
|
||||||
//assign pool devices if any
|
//assign pool devices if any
|
||||||
if(!empty_string((opt = get_pool_setting(work->pool->devices, ((!empty_string(default_profile.devices))?default_profile.devices:"all"))))) {
|
if(!empty_string((opt = get_pool_setting(work->pool->devices, ((!empty_string(default_profile.devices))?default_profile.devices:"all"))))) {
|
||||||
if (opt_removedisabled) {
|
set_devices((char *)opt);
|
||||||
applog(LOG_ERR, "Changing enabled devices is not possible when remove-disabled is set.");
|
|
||||||
} else {
|
|
||||||
set_devices((char *)opt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7375,7 +7360,8 @@ static void *watchdog_thread(void __maybe_unused *userdata)
|
|||||||
count = 0;
|
count = 0;
|
||||||
for (i = 0; i < total_devices; i++) {
|
for (i = 0; i < total_devices; i++) {
|
||||||
cgpu = get_devices(i);
|
cgpu = get_devices(i);
|
||||||
if (cgpu) curses_print_devstatus(cgpu, count++);
|
if (cgpu && (!opt_removedisabled || cgpu->deven != DEV_DISABLED))
|
||||||
|
curses_print_devstatus(cgpu, count++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8000,13 +7986,11 @@ void fill_device_drv(struct device_drv *drv)
|
|||||||
drv->working_diff = 1;
|
drv->working_diff = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enable_device(struct cgpu_info *cgpu)
|
void enable_device(int i)
|
||||||
{
|
{
|
||||||
cgpu->deven = DEV_ENABLED;
|
rd_lock(&devices_lock);
|
||||||
|
devices[i]->deven = DEV_ENABLED;
|
||||||
wr_lock(&devices_lock);
|
rd_unlock(&devices_lock);
|
||||||
devices[cgpu->sgminer_id = sgminer_id_count++] = cgpu;
|
|
||||||
wr_unlock(&devices_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _cgpu_devid_counter {
|
struct _cgpu_devid_counter {
|
||||||
@ -8410,19 +8394,17 @@ int main(int argc, char *argv[])
|
|||||||
if (devices_enabled[i]) {
|
if (devices_enabled[i]) {
|
||||||
if (i >= total_devices)
|
if (i >= total_devices)
|
||||||
quit (1, "Command line options set a device that doesn't exist");
|
quit (1, "Command line options set a device that doesn't exist");
|
||||||
enable_device(devices[i]);
|
enable_device(i);
|
||||||
mining_threads += devices[i]->threads;
|
mining_threads += devices[i]->threads;
|
||||||
} else if (i < total_devices) {
|
} else if (i < total_devices) {
|
||||||
if (!opt_removedisabled) {
|
|
||||||
enable_device(devices[i]);
|
|
||||||
mining_threads += devices[i]->threads;
|
|
||||||
}
|
|
||||||
devices[i]->deven = DEV_DISABLED;
|
devices[i]->deven = DEV_DISABLED;
|
||||||
|
if (!opt_removedisabled)
|
||||||
|
mining_threads += devices[i]->threads;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < total_devices; ++i) {
|
for (i = 0; i < total_devices; ++i) {
|
||||||
enable_device(devices[i]);
|
enable_device(i);
|
||||||
mining_threads += devices[i]->threads;
|
mining_threads += devices[i]->threads;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user