Browse Source

check for clients that really need to reconnect and do them asap

master
Con Kolivas 10 years ago
parent
commit
4e5ccb6e13
  1. 22
      src/stratifier.c

22
src/stratifier.c

@ -259,6 +259,7 @@ struct stratum_instance {
* or other problem and should be dropped lazily if * or other problem and should be dropped lazily if
* this is set to 2 */ * this is set to 2 */
bool reconnect; /* This client really needs to reconnect */
time_t reconnect_request; /* The time we sent a reconnect message */ time_t reconnect_request; /* The time we sent a reconnect message */
user_instance_t *user_instance; user_instance_t *user_instance;
@ -1381,11 +1382,14 @@ static void reconnect_clients(sdata_t *sdata)
continue; continue;
if (!client->authorised) if (!client->authorised)
continue; continue;
/* This client is bound to a user proxy */ /* Is this client boudn to a dead proxy? */
if (client->proxy->userid) if (!client->reconnect) {
continue; /* This client is bound to a user proxy */
if (client->proxyid == proxy->id) if (client->proxy->userid)
continue; continue;
if (client->proxyid == proxy->id)
continue;
}
if (headroom-- < 1) if (headroom-- < 1)
continue; continue;
reconnects++; reconnects++;
@ -1468,8 +1472,10 @@ static void dead_proxyid(sdata_t *sdata, const int id, const int subid)
/* Clients could remain connected to a dead connection here /* Clients could remain connected to a dead connection here
* but should be picked up when we recruit enough slots after * but should be picked up when we recruit enough slots after
* another notify. */ * another notify. */
if (headroom-- < 1) if (headroom-- < 1) {
client->reconnect = true;
continue; continue;
}
reconnects++; reconnects++;
reconnect_client(sdata, client); reconnect_client(sdata, client);
} }
@ -1620,7 +1626,8 @@ static void check_userproxies(sdata_t *sdata, const int userid)
continue; continue;
if (client->user_id != userid) if (client->user_id != userid)
continue; continue;
if (client->proxy->userid == userid) /* Is this client bound to a dead proxy? */
if (!client->reconnect && client->proxy->userid == userid)
continue; continue;
if (headroom-- < 1) if (headroom-- < 1)
continue; continue;
@ -2442,6 +2449,7 @@ static void reconnect_client_id(sdata_t *sdata, const int64_t client_id)
LOGINFO("reconnect_client_id failed to find client %"PRId64, client_id); LOGINFO("reconnect_client_id failed to find client %"PRId64, client_id);
return; return;
} }
client->reconnect = true;
reconnect_client(sdata, client); reconnect_client(sdata, client);
dec_instance_ref(sdata, client); dec_instance_ref(sdata, client);
} }

Loading…
Cancel
Save