Test for rolltime and save it correctly when testing for longpoll.
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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
diff --git a/main.c b/main.c
index aa6bd43..096915d 100644
--- a/main.c
+++ b/main.c
@@ -775,7 +775,7 @@ static bool submit_upstream_work(const struct work *work)
applog(LOG_DEBUG, "DBG: sending RPC call: %s", s);
/* issue JSON-RPC request */
- val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, s, false, false, false, pool);
+ val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, s, false, false, pool);
if (unlikely(!val)) {
applog(LOG_INFO, "submit_upstream_work json_rpc_call failed");
if (!pool_tset(pool, &pool->submit_fail)) {
@@ -847,7 +847,7 @@ static bool get_upstream_work(struct work *work)
}
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
- want_longpoll, false, false, pool);
+ want_longpoll, false, pool);
if (unlikely(!val)) {
applog(LOG_DEBUG, "Failed json_rpc_call in get_upstream_work");
goto out;
@@ -2031,7 +2031,7 @@ next_path:
gettimeofday(&start, NULL);
val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req,
- false, true, false, pool);
+ false, true, pool);
if (likely(val)) {
/* Keep track of who ordered a restart_threads to make
* sure it's only done once per new block */
@@ -2294,7 +2294,6 @@ int main (int argc, char *argv[])
struct thr_info *thr;
char name[256];
struct tm tm;
- struct pool *pool;
/* This dangerous functions tramples random dynamically allocated
* variables so do it before anything at all */
@@ -2374,9 +2373,6 @@ int main (int argc, char *argv[])
return 1;
}
- set_current_pool(pools);
- pool = current_pool();
-
if (total_devices) {
if (total_devices > nDevs) {
applog(LOG_ERR, "More devices specified than exist");
@@ -2407,26 +2403,31 @@ int main (int argc, char *argv[])
logstart = cpucursor + (opt_n_threads ? num_processors : 0) + 1;
logcursor = logstart + 1;
- if (!pool->rpc_userpass) {
- if (!pool->rpc_user || !pool->rpc_pass) {
- applog(LOG_ERR, "No login credentials supplied");
- return 1;
- }
- pool->rpc_userpass = malloc(strlen(pool->rpc_user) + strlen(pool->rpc_pass) + 2);
- if (!pool->rpc_userpass)
- return 1;
- sprintf(pool->rpc_userpass, "%s:%s", pool->rpc_user, pool->rpc_pass);
- } else {
- pool->rpc_user = malloc(strlen(pool->rpc_userpass));
- if (!pool->rpc_user)
- return 1;
- strcpy(pool->rpc_user, pool->rpc_userpass);
- pool->rpc_user = strtok(pool->rpc_user, ":");
- if (!pool->rpc_user) {
- applog(LOG_ERR, "Failed to find colon delimiter in userpass");
- return 1;
+ for (i = 0; i < total_pools; i++) {
+ struct pool *pool = &pools[i];
+
+ if (!pool->rpc_userpass) {
+ if (!pool->rpc_user || !pool->rpc_pass) {
+ applog(LOG_ERR, "No login credentials supplied for pool %u %s", i, pool->rpc_url);
+ return 1;
+ }
+ pool->rpc_userpass = malloc(strlen(pool->rpc_user) + strlen(pool->rpc_pass) + 2);
+ if (!pool->rpc_userpass)
+ return 1;
+ sprintf(pool->rpc_userpass, "%s:%s", pool->rpc_user, pool->rpc_pass);
+ } else {
+ pool->rpc_user = malloc(strlen(pool->rpc_userpass));
+ if (!pool->rpc_user)
+ return 1;
+ strcpy(pool->rpc_user, pool->rpc_userpass);
+ pool->rpc_user = strtok(pool->rpc_user, ":");
+ if (!pool->rpc_user) {
+ applog(LOG_ERR, "Failed to find colon delimiter in userpass");
+ return 1;
+ }
}
}
+ set_current_pool(pools);
#ifdef HAVE_SYSLOG_H
if (use_syslog)
diff --git a/miner.h b/miner.h
index 4d0ef1d..1442be0 100644
--- a/miner.h
+++ b/miner.h
@@ -182,8 +182,7 @@ extern bool opt_protocol;
extern bool opt_log_output;
extern const uint32_t sha256_init_state[];
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
- const char *rpc_req, bool, bool, bool,
- struct pool *pool);
+ const char *rpc_req, bool, bool, struct pool *pool);
extern char *bin2hex(const unsigned char *p, size_t len);
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
diff --git a/util.c b/util.c
index 9d4b854..cabcfa7 100644
--- a/util.c
+++ b/util.c
@@ -68,6 +68,7 @@ struct upload_buffer {
struct header_info {
char *lp_path;
+ bool has_rolltime;
};
struct tq_ent {
@@ -186,8 +187,7 @@ static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
return len;
}
-static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data,
- struct pool *pool)
+static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
{
struct header_info *hi = user_data;
size_t remlen, slen, ptrlen = size * nmemb;
@@ -228,7 +228,7 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data,
if (!strcasecmp("X-Roll-Ntime", key)) {
applog(LOG_INFO, "X-Roll-Ntime found");
- pool->has_rolltime = true;
+ hi->has_rolltime = true;
}
if (!strcasecmp("X-Long-Polling", key)) {
@@ -247,7 +247,7 @@ static bool comms_error = false;
json_t *json_rpc_call(CURL *curl, const char *url,
const char *userpass, const char *rpc_req,
bool longpoll_scan, bool longpoll,
- bool getroll, struct pool *pool)
+ struct pool *pool)
{
json_t *val, *err_val, *res_val;
int rc;
@@ -278,7 +278,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_data);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_err_str);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
- if (lp_scanning || getroll) {
+ if (lp_scanning) {
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, resp_hdr_cb);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &hi);
}
@@ -329,6 +329,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
tq_push(thr_info[longpoll_thr_id].q, hi.lp_path);
} else
free(hi.lp_path);
+ pool->has_rolltime = hi.has_rolltime;
}
hi.lp_path = NULL;