Browse Source

Update webconfig code to latest BFGMiner

Luke Dashjr 11 years ago
parent
commit
c283ef9e33
3 changed files with 12 additions and 34 deletions
  1. 8 20
      miner.c
  2. 0 6
      miner.h
  3. 4 8
      util.c

+ 8 - 20
miner.c

@@ -395,13 +395,9 @@ static int include_count;
 #define JSON_LOAD_ERROR_LEN strlen(JSON_LOAD_ERROR)
 #define JSON_LOAD_ERROR_LEN strlen(JSON_LOAD_ERROR)
 #define JSON_MAX_DEPTH 10
 #define JSON_MAX_DEPTH 10
 #define JSON_MAX_DEPTH_ERR "Too many levels of JSON includes (limit 10) or a loop"
 #define JSON_MAX_DEPTH_ERR "Too many levels of JSON includes (limit 10) or a loop"
-<<<<<<<
+#define JSON_WEB_ERROR "WEB config err"
 
 
 char *cmd_idle, *cmd_sick, *cmd_dead;
 char *cmd_idle, *cmd_sick, *cmd_dead;
-|||||||
-=======
-#define JSON_WEB_ERROR "WEB config err"
->>>>>>>
 
 
 #if defined(unix) || defined(__APPLE__)
 #if defined(unix) || defined(__APPLE__)
 	static char *opt_stderr_cmd = NULL;
 	static char *opt_stderr_cmd = NULL;
@@ -2908,6 +2904,7 @@ static char *load_web_config(const char *arg)
 {
 {
 	json_t *val;
 	json_t *val;
 	CURL *curl;
 	CURL *curl;
+	struct bfg_loaded_configfile *cfginfo;
 
 
 	curl = curl_easy_init();
 	curl = curl_easy_init();
 	if (unlikely(!curl))
 	if (unlikely(!curl))
@@ -2920,12 +2917,15 @@ static char *load_web_config(const char *arg)
 	if (!val || !json_is_object(val))
 	if (!val || !json_is_object(val))
 		return JSON_WEB_ERROR;
 		return JSON_WEB_ERROR;
 
 
-	if (!cnfbuf)
-		cnfbuf = strdup(arg);
+	cfginfo = malloc(sizeof(*cfginfo));
+	*cfginfo = (struct bfg_loaded_configfile){
+		.filename = strdup(arg),
+	};
+	LL_APPEND(bfg_loaded_configfiles, cfginfo);
 
 
 	config_loaded = true;
 	config_loaded = true;
 
 
-	return parse_config(val, true);
+	return parse_config(val, true, &cfginfo->fileconf_load);
 }
 }
 
 
 static char *load_config(const char *arg, void __maybe_unused *unused)
 static char *load_config(const char *arg, void __maybe_unused *unused)
@@ -2934,23 +2934,11 @@ static char *load_config(const char *arg, void __maybe_unused *unused)
 	json_t *config;
 	json_t *config;
 	char *json_error;
 	char *json_error;
 	size_t siz;
 	size_t siz;
-<<<<<<<
 	struct bfg_loaded_configfile *cfginfo;
 	struct bfg_loaded_configfile *cfginfo;
-|||||||
-
-	if (!cnfbuf)
-		cnfbuf = strdup(arg);
-=======
 
 
-#ifdef HAVE_LIBCURL
 	if (strncasecmp(arg, conf_web1, sizeof(conf_web1)-1) == 0 ||
 	if (strncasecmp(arg, conf_web1, sizeof(conf_web1)-1) == 0 ||
 	    strncasecmp(arg, conf_web2, sizeof(conf_web2)-1) == 0)
 	    strncasecmp(arg, conf_web2, sizeof(conf_web2)-1) == 0)
 		return load_web_config(arg);
 		return load_web_config(arg);
-#endif
-
-	if (!cnfbuf)
-		cnfbuf = strdup(arg);
->>>>>>>
 
 
 	cfginfo = malloc(sizeof(*cfginfo));
 	cfginfo = malloc(sizeof(*cfginfo));
 	*cfginfo = (struct bfg_loaded_configfile){
 	*cfginfo = (struct bfg_loaded_configfile){

+ 0 - 6
miner.h

@@ -1016,13 +1016,7 @@ extern int swork_id;
 extern pthread_rwlock_t netacc_lock;
 extern pthread_rwlock_t netacc_lock;
 
 
 extern const uint32_t sha256_init_state[];
 extern const uint32_t sha256_init_state[];
-<<<<<<< HEAD
-||||||| parent of c7d6886... allow url based config files
-#ifdef HAVE_LIBCURL
-=======
-#ifdef HAVE_LIBCURL
 extern json_t *json_web_config(CURL *curl, const char *url);
 extern json_t *json_web_config(CURL *curl, const char *url);
->>>>>>> c7d6886... allow url based config files
 extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
 extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
 			     const char *rpc_req, bool, bool, int *,
 			     const char *rpc_req, bool, bool, int *,
 			     struct pool *pool, bool);
 			     struct pool *pool, bool);

+ 4 - 8
util.c

@@ -450,11 +450,6 @@ static int curl_debug_cb(__maybe_unused CURL *handle, curl_infotype type,
 	return 0;
 	return 0;
 }
 }
 
 
-<<<<<<< HEAD
-void json_rpc_call_async(CURL *curl, const char *url,
-||||||| parent of c7d6886... allow url based config files
-json_t *json_rpc_call(CURL *curl, const char *url,
-=======
 json_t *json_web_config(CURL *curl, const char *url)
 json_t *json_web_config(CURL *curl, const char *url)
 {
 {
 	struct data_buffer all_data = {NULL, 0};
 	struct data_buffer all_data = {NULL, 0};
@@ -468,6 +463,9 @@ json_t *json_web_config(CURL *curl, const char *url)
 
 
 	/* it is assumed that 'curl' is freshly [re]initialized at this pt */
 	/* it is assumed that 'curl' is freshly [re]initialized at this pt */
 
 
+	curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
+	curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
+	
 	curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
 	curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
 
 
 	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
 	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
@@ -505,12 +503,10 @@ json_t *json_web_config(CURL *curl, const char *url)
 c_out:
 c_out:
 	databuf_free(&all_data);
 	databuf_free(&all_data);
 	curl_easy_reset(curl);
 	curl_easy_reset(curl);
-	curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
 	return val;
 	return val;
 }
 }
 
 
-json_t *json_rpc_call(CURL *curl, const char *url,
->>>>>>> c7d6886... allow url based config files
+void json_rpc_call_async(CURL *curl, const char *url,
 		      const char *userpass, const char *rpc_req,
 		      const char *userpass, const char *rpc_req,
 		      bool longpoll,
 		      bool longpoll,
 		      struct pool *pool, bool share,
 		      struct pool *pool, bool share,