Browse Source

Merge branch 'master' of https://github.com/ckolivas/cgminer.git

nfactor-troky
Paul Sheppard 12 years ago
parent
commit
3858e991f0
  1. 8
      NEWS
  2. 29
      cgminer.c
  3. 2
      configure.ac
  4. 1
      miner.h
  5. 20
      util.c

8
NEWS

@ -1,3 +1,11 @@ @@ -1,3 +1,11 @@
Version 2.8.7 - October 29, 2012
- Fail on select() failing in stratum thread without needing to attempt
recv_line.
- Add share to stratum database before sending it again in case we get a
response from the pool before it's added.
Version 2.8.6 - October 29, 2012
- Shorten the initiate stratum connect timeout to 30 seconds.

29
cgminer.c

@ -2915,36 +2915,38 @@ static void *submit_work_thread(void *userdata) @@ -2915,36 +2915,38 @@ static void *submit_work_thread(void *userdata)
}
if (work->stratum) {
struct stratum_share *sshare = calloc(sizeof(struct stratum_share), 1);
uint32_t *hash32 = (uint32_t *)work->hash, nonce;
char *noncehex;
char s[1024];
memcpy(&sshare->work, work, sizeof(struct work));
mutex_lock(&sshare_lock);
/* Give the stratum share a unique id */
swork_id++;
sshare->id = swork_id++;
HASH_ADD_INT(stratum_shares, id, sshare);
mutex_unlock(&sshare_lock);
nonce = *((uint32_t *)(work->data + 76));
noncehex = bin2hex((const unsigned char *)&nonce, 4);
memset(s, 0, 1024);
sprintf(s, "{\"params\": [\"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\": %d, \"method\": \"mining.submit\"}",
pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, swork_id);
pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, sshare->id);
free(noncehex);
applog(LOG_INFO, "Submitting share %08lx to pool %d", (unsigned long)(hash32[6]), pool->pool_no);
if (likely(stratum_send(pool, s, strlen(s)))) {
struct stratum_share *sshare = calloc(sizeof(struct stratum_share), 1);
if (pool_tclear(pool, &pool->submit_fail))
applog(LOG_WARNING, "Pool %d communication resumed, submitting work", pool->pool_no);
applog(LOG_DEBUG, "Successfully submitted, adding to stratum_shares db");
memcpy(&sshare->work, work, sizeof(struct work));
mutex_lock(&sshare_lock);
sshare->id = swork_id;
HASH_ADD_INT(stratum_shares, id, sshare);
mutex_unlock(&sshare_lock);
} else {
applog(LOG_INFO, "Failed to submit stratum share");
mutex_lock(&sshare_lock);
HASH_DEL(stratum_shares, sshare);
mutex_unlock(&sshare_lock);
free(sshare);
if (!pool_tset(pool, &pool->submit_fail)) {
total_ro++;
pool->remotefail_occasions++;
@ -4330,7 +4332,9 @@ static void *stratum_thread(void *userdata) @@ -4330,7 +4332,9 @@ static void *stratum_thread(void *userdata)
* every minute so if we fail to receive any for 90 seconds we
* assume the connection has been dropped and treat this pool
* as dead */
select(pool->sock + 1, &rd, NULL, NULL, &timeout);
if (unlikely(select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1))
s = NULL;
else
s = recv_line(pool);
if (!s) {
applog(LOG_INFO, "Stratum connection to pool %d interrupted", pool->pool_no);
@ -4357,6 +4361,7 @@ static void *stratum_thread(void *userdata) @@ -4357,6 +4361,7 @@ static void *stratum_thread(void *userdata)
free(s);
if (pool->swork.clean) {
struct work work;
memset(&work, 0, sizeof(work));
/* Generate a single work item to update the current
* block database */

2
configure.ac

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_define([v_maj], [2])
m4_define([v_min], [8])
m4_define([v_mic], [6])
m4_define([v_mic], [7])
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_define([v_ver], [v_maj.v_min.v_mic])
m4_define([lt_rev], m4_eval(v_maj + v_min))

1
miner.h

@ -872,7 +872,6 @@ struct pool { @@ -872,7 +872,6 @@ struct pool {
CURL *stratum_curl;
SOCKETTYPE sock;
char sockbuf[RBUFSIZE];
struct sockaddr_in *server, client;
char *sockaddr_url; /* stripped url used for sockaddr */
char *nonce1;
uint32_t nonce2;

20
util.c

@ -836,7 +836,6 @@ bool extract_sockaddr(struct pool *pool, char *url) @@ -836,7 +836,6 @@ bool extract_sockaddr(struct pool *pool, char *url)
{
char *url_begin, *url_end, *port_start = NULL;
char url_address[256], port[6];
struct addrinfo hints, *res;
int url_len, port_len = 0;
pool->sockaddr_url = url;
@ -866,18 +865,6 @@ bool extract_sockaddr(struct pool *pool, char *url) @@ -866,18 +865,6 @@ bool extract_sockaddr(struct pool *pool, char *url)
strcpy(port, "80");
pool->stratum_port = strdup(port);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if (getaddrinfo(url_address, port, &hints, &res)) {
applog(LOG_DEBUG, "Failed to extract sock addr");
return false;
}
pool->server = (struct sockaddr_in *)res->ai_addr;
pool->sockaddr_url = strdup(url_address);
return true;
@ -1097,6 +1084,13 @@ static bool parse_notify(struct pool *pool, json_t *val) @@ -1097,6 +1084,13 @@ static bool parse_notify(struct pool *pool, json_t *val)
}
mutex_lock(&pool->pool_lock);
free(pool->swork.job_id);
free(pool->swork.prev_hash);
free(pool->swork.coinbase1);
free(pool->swork.coinbase2);
free(pool->swork.bbversion);
free(pool->swork.nbit);
free(pool->swork.ntime);
pool->swork.job_id = job_id;
pool->swork.prev_hash = prev_hash;
pool->swork.coinbase1 = coinbase1;

Loading…
Cancel
Save