stratum: reduce socket timeouts to fight zombie miners

a normal socket send op is < 1ms unless something happened to this
socket connection, generally a permanent disconnect...
This commit is contained in:
Tanguy Pruvot 2017-08-09 08:18:05 +02:00
parent 90a100462d
commit bbaf7b79c6

View file

@ -87,8 +87,8 @@ void job_broadcast(YAAMP_JOB *job)
int s1 = current_timestamp_dms();
int count = 0;
struct timeval timeout;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
timeout.tv_sec = 0;
timeout.tv_usec = 100000; // max time to push to a socket (very fast)
YAAMP_JOB_TEMPLATE *templ = job->templ;
@ -115,10 +115,10 @@ void job_broadcast(YAAMP_JOB *job)
if (socket_send_raw(client->sock, buffer, strlen(buffer)) == -1) {
int err = errno;
client->broadcast_timeouts++;
clientlog(client, "unable to send job, sock err %d (%d times)", err, client->broadcast_timeouts);
// too much timeouts, disconnect him
if (client->broadcast_timeouts >= 3) {
shutdown(client->sock->sock, SHUT_RDWR);
clientlog(client, "unable to send job, sock err %d (%d times)", err, client->broadcast_timeouts);
if(client->workerid && !client->reconnecting) {
// CommonLock(&g_db_mutex);
db_clear_worker(g_db, client);