Browse Source

Handle reconnect message differently for parent proxy than child subproxies

master
Con Kolivas 10 years ago
parent
commit
d0f557bbf8
  1. 12
      src/generator.c
  2. 11
      src/stratifier.c

12
src/generator.c

@ -105,6 +105,7 @@ struct proxy_instance {
bool disabled; /* Subproxy no longer to be used */ bool disabled; /* Subproxy no longer to be used */
bool reconnect; /* We need to drop and reconnect */ bool reconnect; /* We need to drop and reconnect */
bool reconnecting; /* Parsed reconnect, need to reconnect clients */
bool alive; bool alive;
pthread_mutex_t notify_lock; pthread_mutex_t notify_lock;
@ -1805,14 +1806,18 @@ static void *proxy_recv(void *arg)
/* Call this proxy dead to allow us to fail /* Call this proxy dead to allow us to fail
* over to a backup pool until the reconnect * over to a backup pool until the reconnect
* pool is up */ * pool is up */
Close(cs->fd);
subproxy->reconnect = false; subproxy->reconnect = false;
alive = subproxy->alive = false; subproxy->reconnecting = true;
subproxy->alive = false;
if (parent_proxy(subproxy)) {
alive = false;
send_proc(ckp->generator, "reconnect"); send_proc(ckp->generator, "reconnect");
LOGWARNING("Proxy %d:%s reconnect issue, dropping existing connection", LOGWARNING("Proxy %d:%s reconnect issue, dropping existing connection",
subproxy->id, subproxy->si->url); subproxy->id, subproxy->si->url);
Close(cs->fd);
break; break;
} }
}
continue; continue;
} }
if (parse_share(subproxy, cs->buf)) { if (parse_share(subproxy, cs->buf)) {
@ -1902,7 +1907,8 @@ reconnect:
cproxy = best_proxy(ckp, gdata); cproxy = best_proxy(ckp, gdata);
if (!cproxy) if (!cproxy)
goto out; goto out;
if (proxi != cproxy) { if (proxi != cproxy || cproxy->reconnecting) {
cproxy->reconnecting = false;
proxi = cproxy; proxi = cproxy;
if (!ckp->passthrough) { if (!ckp->passthrough) {
connsock_t *cs = proxi->cs; connsock_t *cs = proxi->cs;

11
src/stratifier.c

@ -1102,15 +1102,13 @@ static proxy_t *subproxy_by_id(sdata_t *sdata, const int id, const int subid)
} }
/* Iterates over all clients in proxy mode and sets the reconnect bool for the /* Iterates over all clients in proxy mode and sets the reconnect bool for the
* message to be sent lazily next time they speak to us if they're not bound * message to be sent lazily next time they speak to us */
* to the requested proxy id */ static void reconnect_clients(sdata_t *sdata)
static void reconnect_clients_to(sdata_t *sdata, const int id)
{ {
stratum_instance_t *client, *tmp; stratum_instance_t *client, *tmp;
ck_rlock(&sdata->instance_lock); ck_rlock(&sdata->instance_lock);
HASH_ITER(hh, sdata->stratum_instances, client, tmp) { HASH_ITER(hh, sdata->stratum_instances, client, tmp) {
if (client->proxyid != id)
client->reconnect = true; client->reconnect = true;
} }
ck_runlock(&sdata->instance_lock); ck_runlock(&sdata->instance_lock);
@ -1269,7 +1267,7 @@ static void update_notify(ckpool_t *ckp, const char *cmd)
* clients now to reconnect since we have enough information to * clients now to reconnect since we have enough information to
* switch. */ * switch. */
proxy->notified = true; proxy->notified = true;
reconnect_clients_to(sdata, id); reconnect_clients(sdata);
} }
LOGINFO("Broadcast updated stratum notify"); LOGINFO("Broadcast updated stratum notify");
stratum_broadcast_update(dsdata, new_block | clean); stratum_broadcast_update(dsdata, new_block | clean);
@ -1913,7 +1911,8 @@ static char *stratifier_stats(ckpool_t *ckp, sdata_t *sdata)
} }
/* Sets the currently active proxy. Clients will be told to reconnect once the /* Sets the currently active proxy. Clients will be told to reconnect once the
* first notify data comes from this proxy. */ * first notify data comes from this proxy. Even if we are already bound to
* this proxy we are only given this message if all clients must move. */
static void set_proxy(sdata_t *sdata, const char *buf) static void set_proxy(sdata_t *sdata, const char *buf)
{ {
proxy_t *proxy; proxy_t *proxy;

Loading…
Cancel
Save