Commit e0c66a028334a0d1b9f923944dce0b817bc35153

Con Kolivas 2014-03-29T11:54:46

Clean up various curl build issues

diff --git a/cgminer.c b/cgminer.c
index f63d5c1..fa7ff60 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1650,21 +1650,13 @@ static char *parse_config(json_t *config, bool fileconf)
 
 char *cnfbuf = NULL;
 
+#ifdef HAVE_LIBCURL
 char conf_web1[] = "http://";
 char conf_web2[] = "https://";
 
 static char *load_web_config(const char *arg)
 {
-	json_t *val;
-	CURL *curl;
-
-	curl = curl_easy_init();
-	if (unlikely(!curl))
-		quithere(1, "CURL initialisation failed");
-
-	val = json_web_config(curl, arg);
-
-	curl_easy_cleanup(curl);
+	json_t *val = json_web_config(arg);
 
 	if (!val || !json_is_object(val))
 		return JSON_WEB_ERROR;
@@ -1676,6 +1668,7 @@ static char *load_web_config(const char *arg)
 
 	return parse_config(val, true);
 }
+#endif
 
 static char *load_config(const char *arg, void __maybe_unused *unused)
 {
@@ -6457,6 +6450,7 @@ static bool stratum_works(struct pool *pool)
 	return true;
 }
 
+#ifdef HAVE_LIBCURL
 static void __setup_gbt_solo(struct pool *pool)
 {
 	cg_wlock(&pool->gbt_lock);
@@ -6514,6 +6508,12 @@ out:
 		json_decref(val);
 	return ret;
 }
+#else
+static bool setup_gbt_solo(CURL __maybe_unused *curl, struct pool __maybe_unused *pool)
+{
+	return false;
+}
+#endif
 
 static void pool_start_lp(struct pool *pool)
 {
@@ -6959,6 +6959,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 	cgtime(&work->tv_staged);
 }
 
+#ifdef HAVE_LIBCURL
 static void gen_solo_work(struct pool *pool, struct work *work);
 
 /* Use the one instance of gbt_curl, protecting the bool with the gbt_lock but
@@ -7099,6 +7100,7 @@ static void gen_solo_work(struct pool *pool, struct work *work)
 
 	cgtime(&work->tv_staged);
 }
+#endif
 
 /* The time difference in seconds between when this device last got work via
  * get_work() and generated a valid share. */
diff --git a/miner.h b/miner.h
index 1d79c0e..607f433 100644
--- a/miner.h
+++ b/miner.h
@@ -1027,7 +1027,7 @@ extern pthread_rwlock_t netacc_lock;
 
 extern const uint32_t sha256_init_state[];
 #ifdef HAVE_LIBCURL
-extern json_t *json_web_config(CURL *curl, const char *url);
+extern json_t *json_web_config(const char *url);
 extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
 			     const char *rpc_req, bool, bool, int *,
 			     struct pool *pool, bool);
diff --git a/util.c b/util.c
index 921aa75..a593832 100644
--- a/util.c
+++ b/util.c
@@ -296,18 +296,21 @@ static int curl_debug_cb(__maybe_unused CURL *handle, curl_infotype type,
 	return 0;
 }
 
-json_t *json_web_config(CURL *curl, const char *url)
+json_t *json_web_config(const char *url)
 {
 	struct data_buffer all_data = {NULL, 0};
 	char curl_err_str[CURL_ERROR_SIZE];
-	json_error_t err;
 	long timeout = 60;
+	json_error_t err;
 	json_t *val;
+	CURL *curl;
 	int rc;
 
 	memset(&err, 0, sizeof(err));
 
-	/* it is assumed that 'curl' is freshly [re]initialized at this pt */
+	curl = curl_easy_init();
+	if (unlikely(!curl))
+		quithere(1, "CURL initialisation failed");
 
 	curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
 
@@ -324,29 +327,25 @@ json_t *json_web_config(CURL *curl, const char *url)
 
 	val = NULL;
 	rc = curl_easy_perform(curl);
+	curl_easy_cleanup(curl);
 	if (rc) {
-		applog(LOG_ERR, "HTTP config request of '%s' failed: %s",
-				url, curl_err_str);
+		applog(LOG_ERR, "HTTP config request of '%s' failed: %s", url, curl_err_str);
 		goto c_out;
 	}
 
 	if (!all_data.buf) {
-		applog(LOG_ERR, "Empty config data received from '%s'",
-				url);
+		applog(LOG_ERR, "Empty config data received from '%s'", url);
 		goto c_out;
 	}
 
 	val = JSON_LOADS(all_data.buf, &err);
 	if (!val) {
-		applog(LOG_ERR, "JSON config decode of '%s' failed(%d): %s",
-				url, err.line, err.text);
-		goto c_out;
+		applog(LOG_ERR, "JSON config decode of '%s' failed(%d): %s", url,
+		       err.line, err.text);
 	}
 
 c_out:
 	databuf_free(&all_data);
-	curl_easy_reset(curl);
-	curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
 	return val;
 }