diff --git a/cgminer.c b/cgminer.c index 16c3955d..db132b13 100644 --- a/cgminer.c +++ b/cgminer.c @@ -5594,9 +5594,9 @@ static bool input_pool(bool live) pool = add_pool(); - if (!detect_stratum(pool, url) && - strncmp(url, "http://", 7) && - strncmp(url, "https://", 8)) { + if (detect_stratum(pool, url)) + url = strdup(pool->stratum_url); + else if (strncmp(url, "http://", 7) && strncmp(url, "https://", 8)) { char *httpinput; httpinput = malloc(255); @@ -5606,8 +5606,7 @@ static bool input_pool(bool live) strncat(httpinput, url, 248); free(url); url = httpinput; - } else - url = strdup(pool->stratum_url); + } add_pool_details(pool, live, url, user, pass); ret = true; diff --git a/miner.h b/miner.h index fb30ac94..9143ebc8 100644 --- a/miner.h +++ b/miner.h @@ -834,6 +834,7 @@ struct pool { char *stratum_url; SOCKETTYPE sock; struct sockaddr_in *server, client; + char *sockaddr_url; /* stripped url used for sockaddr */ char *subscription; char *nonce1; uint32_t nonce2; diff --git a/util.c b/util.c index b81af61d..89d7a0fd 100644 --- a/util.c +++ b/util.c @@ -809,7 +809,7 @@ double tdiff(struct timeval *end, struct timeval *start) bool extract_sockaddr(struct pool *pool, char *url) { - char *url_begin, *url_end, *port_start; + char *url_begin, *url_end, *port_start = NULL; char *url_address, *port; struct addrinfo hints, *res; int url_len, port_len = 0; @@ -854,7 +854,7 @@ bool extract_sockaddr(struct pool *pool, char *url) } pool->server = (struct sockaddr_in *)res->ai_addr; - pool->stratum_url = strdup(url_address); + pool->sockaddr_url = strdup(url_address); return true; } @@ -1188,7 +1188,7 @@ out: bool initiate_stratum(struct pool *pool) { - json_t *val, *res_val, *err_val, *notify_val; + json_t *val = NULL, *res_val, *err_val, *notify_val; char *s, *buf, *sret = NULL; json_error_t err; bool ret = false; @@ -1281,6 +1281,7 @@ out: json_decref(val); if (ret) { + pool->stratum_url = pool->sockaddr_url; pool->stratum_active = true; pool->swork.diff = 1; if (opt_protocol) {