kanoi 9 years ago
parent
commit
fcabe77d46
  1. 1
      src/connector.c
  2. 13
      src/generator.c
  3. 2
      src/libckpool.h
  4. 14
      src/stratifier.c

1
src/connector.c

@ -864,6 +864,7 @@ retry:
} else if (cmdmatch(buf, "reject")) { } else if (cmdmatch(buf, "reject")) {
LOGDEBUG("Connector received reject signal"); LOGDEBUG("Connector received reject signal");
cdata->accept = false; cdata->accept = false;
send_proc(ckp->stratifier, "dropall");
} else if (cmdmatch(buf, "stats")) { } else if (cmdmatch(buf, "stats")) {
char *msg; char *msg;

13
src/generator.c

@ -1261,9 +1261,9 @@ static void *proxy_recv(void *arg)
while (42) { while (42) {
notify_instance_t *ni, *tmp; notify_instance_t *ni, *tmp;
share_msg_t *share, *tmpshare; share_msg_t *share, *tmpshare;
int retries = 0, ret;
float timeout; float timeout;
time_t now; time_t now;
int ret;
now = time(NULL); now = time(NULL);
@ -1290,14 +1290,14 @@ static void *proxy_recv(void *arg)
/* If we don't get an update within 10 minutes the upstream pool /* If we don't get an update within 10 minutes the upstream pool
* has likely stopped responding. */ * has likely stopped responding. */
timeout = 10; timeout = 600;
do { do {
if (cs->fd == -1) { if (cs->fd == -1) {
ret = -1; ret = -1;
break; break;
} }
ret = read_socket_line(cs, &timeout); ret = read_socket_line(cs, &timeout);
} while (ret == 0 && ++retries < 120); } while (ret == 0 && timeout > 0);
if (ret < 1) { if (ret < 1) {
/* Send ourselves a reconnect message */ /* Send ourselves a reconnect message */
@ -1403,7 +1403,7 @@ static void *passthrough_recv(void *arg)
do { do {
ret = read_socket_line(cs, &timeout); ret = read_socket_line(cs, &timeout);
} while (ret == 0); } while (ret == 0 && timeout > 0);
if (ret < 1) { if (ret < 1) {
/* Send ourselves a reconnect message */ /* Send ourselves a reconnect message */
@ -1538,12 +1538,13 @@ retry:
} }
cs = alive->cs; cs = alive->cs;
LOGNOTICE("Connected to upstream server %s:%s as proxy%s", cs->url, cs->port,
ckp->passthrough ? " in passthrough mode" : "");
if (ckp->passthrough) { if (ckp->passthrough) {
LOGWARNING("Connected to upstream server %s:%s as proxy in passthrough mode",
cs->url, cs->port);
create_pthread(&alive->pth_precv, passthrough_recv, alive); create_pthread(&alive->pth_precv, passthrough_recv, alive);
alive->passsends = create_ckmsgq(ckp, "passsend", &passthrough_send); alive->passsends = create_ckmsgq(ckp, "passsend", &passthrough_send);
} else { } else {
LOGNOTICE("Connected to upstream server %s:%s as proxy", cs->url, cs->port);
create_pthread(&alive->pth_precv, proxy_recv, alive); create_pthread(&alive->pth_precv, proxy_recv, alive);
mutex_init(&alive->psend_lock); mutex_init(&alive->psend_lock);
cond_init(&alive->psend_cond); cond_init(&alive->psend_cond);

2
src/libckpool.h

@ -192,7 +192,7 @@ static inline void flip_80(void *dest_p, const void *src_p)
void logmsg(int loglevel, const char *fmt, ...); void logmsg(int loglevel, const char *fmt, ...);
#define DEFLOGBUFSIZ 512 #define DEFLOGBUFSIZ 1000
#define LOGMSGBUF(__lvl, __buf) do { \ #define LOGMSGBUF(__lvl, __buf) do { \
logmsg(__lvl, "%s", __buf); \ logmsg(__lvl, "%s", __buf); \

14
src/stratifier.c

@ -1064,7 +1064,7 @@ static void drop_allclients(ckpool_t *ckp)
ck_wunlock(&sdata->instance_lock); ck_wunlock(&sdata->instance_lock);
if (kills) if (kills)
LOGNOTICE("Dropped %d instances", kills); LOGNOTICE("Dropped %d instances for dropall request", kills);
} }
static void update_subscribe(ckpool_t *ckp) static void update_subscribe(ckpool_t *ckp)
@ -1370,6 +1370,12 @@ static stratum_instance_t *__stratum_add_instance(ckpool_t *ckp, const int64_t i
return client; return client;
} }
/* passthrough subclients have client_ids in the high bits */
static inline bool passthrough_subclient(const int64_t client_id)
{
return (client_id > 0xffffffffll);
}
static uint64_t disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid, static uint64_t disconnected_sessionid_exists(sdata_t *sdata, const char *sessionid,
int *session_id, const int64_t id) int *session_id, const int64_t id)
{ {
@ -1378,6 +1384,10 @@ static uint64_t disconnected_sessionid_exists(sdata_t *sdata, const char *sessio
uint64_t ret = 0; uint64_t ret = 0;
int slen; int slen;
/* Don't allow passthrough subclients to resume */
if (passthrough_subclient(id))
goto out;
if (!sessionid) if (!sessionid)
goto out; goto out;
slen = strlen(sessionid) / 2; slen = strlen(sessionid) / 2;
@ -1763,7 +1773,7 @@ retry:
LOGDEBUG("%ds elapsed in strat_loop, updating gbt base", LOGDEBUG("%ds elapsed in strat_loop, updating gbt base",
ckp->update_interval); ckp->update_interval);
update_base(ckp, GEN_NORMAL); update_base(ckp, GEN_NORMAL);
} else { } else if (!ckp->passthrough) {
LOGDEBUG("%ds elapsed in strat_loop, pinging miners", LOGDEBUG("%ds elapsed in strat_loop, pinging miners",
ckp->update_interval); ckp->update_interval);
broadcast_ping(sdata); broadcast_ping(sdata);

Loading…
Cancel
Save