Store a sockaddr url of the stripped url used in determining sockaddr to not confuse it with the stratum url and fix build warnings.
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
diff --git a/cgminer.c b/cgminer.c
index 16c3955..db132b1 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 fb30ac9..9143ebc 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 b81af61..89d7a0f 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) {