Browse Source

Initiate stratum the first time in pool_active only, allowing us to switch to it on getting a failed getwork and detecting the presence of stratum on the url at that time.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
1b7aa48c8f
  1. 16
      cgminer.c
  2. 2
      util.c

16
cgminer.c

@ -562,16 +562,11 @@ static char *set_rr(enum pool_strategy *strategy) @@ -562,16 +562,11 @@ static char *set_rr(enum pool_strategy *strategy)
* stratum+tcp or by detecting a stratum server response */
bool detect_stratum(struct pool *pool, char *url)
{
bool stratum;
if (!extract_sockaddr(pool, url))
return false;
stratum = initiate_stratum(pool);
if (!strncasecmp(url, "stratum+tcp://", 14) || stratum) {
if (!strncasecmp(url, "stratum+tcp://", 14)) {
pool->has_stratum = true;
if (!pool->stratum_url)
pool->stratum_url = pool->sockaddr_url;
return true;
}
@ -4205,6 +4200,7 @@ static bool pool_active(struct pool *pool, bool pinging) @@ -4205,6 +4200,7 @@ static bool pool_active(struct pool *pool, bool pinging)
applog(LOG_INFO, "Testing pool %s", pool->rpc_url);
/* This is the central point we activate stratum when we can */
retry_stratum:
if (pool->has_stratum) {
if ((!pool->stratum_active || pinging) && !initiate_stratum(pool))
@ -4233,7 +4229,7 @@ retry_stratum: @@ -4233,7 +4229,7 @@ retry_stratum:
/* Detect if a http getwork pool has an X-Stratum header at startup,
* and if so, switch to that in preference to getwork */
if (unlikely(!pinging && pool->stratum_url)) {
if (unlikely(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->rpc_url = pool->stratum_url;
@ -4308,6 +4304,12 @@ retry_stratum: @@ -4308,6 +4304,12 @@ retry_stratum:
quit(1, "Failed to create pool longpoll thread");
}
} else {
/* If we failed to parse a getwork, this could be a stratum
* url without the prefix stratum+tcp:// so let's check it */
if (initiate_stratum(pool)) {
pool->has_stratum = true;
goto retry_stratum;
}
applog(LOG_DEBUG, "FAILED to retrieve work from pool %u %s",
pool->pool_no, pool->rpc_url);
if (!pinging)

2
util.c

@ -906,7 +906,7 @@ static bool sock_full(SOCKETTYPE sock, bool wait) @@ -906,7 +906,7 @@ static bool sock_full(SOCKETTYPE sock, bool wait)
FD_SET(sock, &rd);
timeout.tv_usec = 0;
if (wait)
timeout.tv_sec = 5;
timeout.tv_sec = 60;
else
timeout.tv_sec = 0;
if (select(sock + 1, &rd, NULL, NULL, &timeout) > 0)

Loading…
Cancel
Save