Clean up various curl build issues
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
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;
}