Browse Source

Merge commit '2941feb' into stratum

Luke Dashjr 13 years ago
parent
commit
441b301912
3 changed files with 14 additions and 12 deletions
  1. 9 9
      miner.c
  2. 1 0
      miner.h
  3. 4 3
      util.c

+ 9 - 9
miner.c

@@ -3161,6 +3161,7 @@ static void *get_work_thread(void *userdata)
 			kill_work();
 			kill_work();
 			free(ret_work);
 			free(ret_work);
 		}
 		}
+		dec_queued(pool);
 		goto out;
 		goto out;
 	}
 	}
 
 
@@ -5088,10 +5089,10 @@ tryagain:
 	if (unlikely(!pinging && pool->stratum_url)) {
 	if (unlikely(!pinging && pool->stratum_url)) {
 		applog(LOG_NOTICE, "Switching pool %d %s to %s", pool->pool_no, pool->rpc_url, pool->stratum_url);
 		applog(LOG_NOTICE, "Switching pool %d %s to %s", pool->pool_no, pool->rpc_url, pool->stratum_url);
 		pool->has_stratum = true;
 		pool->has_stratum = true;
-		pool->rpc_url = strdup(pool->stratum_url);
-		extract_sockaddr(pool, pool->stratum_url);
-		initiate_stratum(pool);
-		auth_stratum(pool);
+		pool->rpc_url = pool->stratum_url;
+		/* pool->stratum_url will be set again in extract_sockaddr */
+		pool->stratum_url = NULL;
+		extract_sockaddr(pool, pool->rpc_url);
 		curl_easy_cleanup(curl);
 		curl_easy_cleanup(curl);
 
 
 		goto  retry_stratum;
 		goto  retry_stratum;
@@ -6611,9 +6612,9 @@ static bool input_pool(bool live)
 
 
 	pool = add_pool();
 	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;
 		char *httpinput;
 
 
 		httpinput = malloc(255);
 		httpinput = malloc(255);
@@ -6623,8 +6624,7 @@ static bool input_pool(bool live)
 		strncat(httpinput, url, 248);
 		strncat(httpinput, url, 248);
 		free(url);
 		free(url);
 		url = httpinput;
 		url = httpinput;
-	} else
-		url = strdup(pool->stratum_url);
+	}
 
 
 	add_pool_details(pool, live, url, user, pass);
 	add_pool_details(pool, live, url, user, pass);
 	ret = true;
 	ret = true;

+ 1 - 0
miner.h

@@ -917,6 +917,7 @@ struct pool {
 	char *stratum_url;
 	char *stratum_url;
 	SOCKETTYPE sock;
 	SOCKETTYPE sock;
 	struct sockaddr_in *server, client;
 	struct sockaddr_in *server, client;
+	char *sockaddr_url; /* stripped url used for sockaddr */
 	char *subscription;
 	char *subscription;
 	char *nonce1;
 	char *nonce1;
 	uint32_t nonce2;
 	uint32_t nonce2;

+ 4 - 3
util.c

@@ -787,7 +787,7 @@ double tdiff(struct timeval *end, struct timeval *start)
 
 
 bool extract_sockaddr(struct pool *pool, char *url)
 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;
 	char *url_address, *port;
 	struct addrinfo hints, *res;
 	struct addrinfo hints, *res;
 	int url_len, port_len = 0;
 	int url_len, port_len = 0;
@@ -832,7 +832,7 @@ bool extract_sockaddr(struct pool *pool, char *url)
 	}
 	}
 
 
 	pool->server = (struct sockaddr_in *)res->ai_addr;
 	pool->server = (struct sockaddr_in *)res->ai_addr;
-	pool->stratum_url = strdup(url_address);
+	pool->sockaddr_url = strdup(url_address);
 	return true;
 	return true;
 }
 }
 
 
@@ -1166,7 +1166,7 @@ out:
 
 
 bool initiate_stratum(struct pool *pool)
 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;
 	char *s, *buf, *sret = NULL;
 	json_error_t err;
 	json_error_t err;
 	bool ret = false;
 	bool ret = false;
@@ -1259,6 +1259,7 @@ out:
 		json_decref(val);
 		json_decref(val);
 
 
 	if (ret) {
 	if (ret) {
+		pool->stratum_url = pool->sockaddr_url;
 		pool->stratum_active = true;
 		pool->stratum_active = true;
 		pool->swork.diff = 1;
 		pool->swork.diff = 1;
 		if (opt_protocol) {
 		if (opt_protocol) {