Browse Source

Config writer fix

Reworked how the config writer works to properly save the config file.
Sometimes settings would get lost in profiles.

Also changed algorithm switch to only perform a soft reset and lowered
the verbosity of the algorithm switcher.
djm34
ystarnaud 11 years ago
parent
commit
f8fcbbcd0a
  1. 2
      api.c
  2. 1090
      config_parser.c
  3. 19
      config_parser.h
  4. 22
      miner.h
  5. 12
      sgminer.c

2
api.c

@ -1370,10 +1370,12 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __ @@ -1370,10 +1370,12 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
root = api_add_const(root, "ADL", (char *)adl, false);
root = api_add_string(root, "ADL in use", adlinuse, false);
root = api_add_const(root, "Strategy", strategies[pool_strategy].s, false);
root = api_add_int(root, "Rotate Period", &opt_rotate_period, false);
root = api_add_int(root, "Log Interval", &opt_log_interval, false);
root = api_add_const(root, "Device Code", DEVICECODE, false);
root = api_add_const(root, "OS", OSINFO, false);
root = api_add_bool(root, "Failover-Only", &opt_fail_only, false);
root = api_add_int(root, "Failover Switch Delay", &opt_fail_switch_delay, false);
root = api_add_int(root, "ScanTime", &opt_scantime, false);
root = api_add_int(root, "Queue", &opt_queue, false);
root = api_add_int(root, "Expiry", &opt_expiry, false);

1090
config_parser.c

File diff suppressed because it is too large Load Diff

19
config_parser.h

@ -7,25 +7,6 @@ @@ -7,25 +7,6 @@
#include "api.h"
#include "algorithm.h"
//helper to check for empty or NULL strings
#ifndef empty_string
#define empty_string(str) ((str && str[0] != '\0')?0:1)
#endif
#ifndef safe_cmp
#define safe_cmp(val1, val2) (((val1 && strcasecmp(val1, val2) != 0) || empty_string(val1))?1:0)
#endif
#ifndef pool_cmp
#define pool_cmp(val1, val2) (((val1 && val2 && strcasecmp(val1, val2) == 0) || empty_string(val1))?1:0)
#endif
#ifndef isnull
#define isnull(str, default_str) ((str == NULL)?default_str:str)
#endif
//helper function to get a gpu option value
#ifndef gpu_opt
#define gpu_opt(i,optname) gpus[i].optname
#endif
//profile structure
struct profile {
int profile_no;

22
miner.h

@ -245,6 +245,27 @@ enum drv_driver { @@ -245,6 +245,27 @@ enum drv_driver {
DRIVER_PARSE_COMMANDS(DRIVER_PROTOTYPE)
#endif
// helper to check for empty or NULL strings
#ifndef empty_string
#define empty_string(str) ((str && str[0] != '\0')?0:1)
#endif
// helper to safely compare strings: 0 = equal, 1 = not equal
#ifndef safe_cmp
#define safe_cmp(val1, val2) ((!empty_string(val1) && !empty_string(val2))?((strcasecmp(val1, val2) == 0)?0:1):((empty_string(val1) && empty_string(val2))?0:1))
#endif
// helper to pick pool settings or default profile settings
#ifndef pool_cmp
#define pool_cmp(val1, val2) (((val1 && val2 && strcasecmp(val1, val2) == 0) || empty_string(val1))?1:0)
#endif
// helper safely output a string
#ifndef isnull
#define isnull(str, default_str) ((str == NULL)?default_str:str)
#endif
// helper to get boolean value out of string
#ifndef strtobool
#define strtobool(str) ((str && (!strcasecmp(str, "true") || !strcasecmp(str, "yes") || !strcasecmp(str, "1")))?true:false)
#endif
enum alive {
LIFE_WELL,
LIFE_SICK,
@ -1003,6 +1024,7 @@ extern struct schedtime schedstop; @@ -1003,6 +1024,7 @@ extern struct schedtime schedstop;
extern char *sgminer_path;
extern int opt_shares;
extern bool opt_fail_only;
extern int opt_fail_switch_delay;
extern bool opt_autofan;
extern bool opt_autoengine;
extern bool use_curses;

12
sgminer.c

@ -6084,10 +6084,6 @@ static unsigned long compare_pool_settings(struct pool *pool1, struct pool *pool @@ -6084,10 +6084,6 @@ static unsigned long compare_pool_settings(struct pool *pool1, struct pool *pool
if(!pool1 || !pool2)
return 0;
//compare algorithm
if(!cmp_algorithm(&pool1->algorithm, &pool2->algorithm))
options |= (SWITCHER_APPLY_ALGO | SWITCHER_HARD_RESET);
//compare pool devices
opt1 = get_pool_setting(pool1->devices, ((!empty_string(default_profile.devices))?default_profile.devices:"all"));
opt2 = get_pool_setting(pool2->devices, ((!empty_string(default_profile.devices))?default_profile.devices:"all"));
@ -6104,6 +6100,10 @@ static unsigned long compare_pool_settings(struct pool *pool1, struct pool *pool @@ -6104,6 +6100,10 @@ static unsigned long compare_pool_settings(struct pool *pool1, struct pool *pool
if(strcasecmp(opt1, opt2) != 0)
options |= (SWITCHER_APPLY_GT | SWITCHER_HARD_RESET);
//compare algorithm
if(!cmp_algorithm(&pool1->algorithm, &pool2->algorithm))
options |= (SWITCHER_APPLY_ALGO | ((!opt_isset(options, SWITCHER_HARD_RESET))?SWITCHER_SOFT_RESET:0));
//lookup gap
opt1 = get_pool_setting(pool1->lookup_gap, default_profile.lookup_gap);
opt2 = get_pool_setting(pool2->lookup_gap, default_profile.lookup_gap);
@ -6258,7 +6258,7 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work) @@ -6258,7 +6258,7 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
{
if((pool_switch_options = compare_pool_settings(pools[mythr->pool_no], work->pool)) == 0)
{
applog(LOG_NOTICE, "No settings change from pool %s...", isnull(get_pool_name(work->pool), ""));
applog(LOG_DEBUG, "No settings change from pool %s...", isnull(get_pool_name(work->pool), ""));
rd_lock(&mining_thr_lock);
@ -6305,7 +6305,7 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work) @@ -6305,7 +6305,7 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
{
const char *opt;
applog(LOG_NOTICE, "Applying pool settings for %s...", isnull(get_pool_name(work->pool), ""));
applog(LOG_DEBUG, "Applying pool settings for %s...", isnull(get_pool_name(work->pool), ""));
rd_lock(&mining_thr_lock);
// Shutdown all threads first (necessary)

Loading…
Cancel
Save