Skip to content

Commit

Permalink
stratum: socket recv timeout config
Browse files Browse the repository at this point in the history
With a default value set to 10mn, better than unlimited (0)
  • Loading branch information
tpruvot committed Mar 16, 2018
1 parent 67d3e6a commit c56969c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stratum/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,21 @@ void socket_real_ip(YAAMP_SOCKET *s)

YAAMP_SOCKET *socket_initialize(int sock)
{
struct timeval timeout;
timeout.tv_sec = g_socket_recv_timeout;
timeout.tv_usec = 0;
YAAMP_SOCKET *s = new YAAMP_SOCKET;
memset(s, 0, sizeof(YAAMP_SOCKET));

s->buflen = 0;
s->sock = sock;

setsockopt(s->sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));

// yaamp_create_mutex(&s->mutex);
// pthread_mutex_lock(&s->mutex);
int res = 0;
if (!g_handle_haproxy_ips) {
int res = 0;
struct sockaddr_in name;
socklen_t len = sizeof(name);
memset(&name, 0, len);
Expand Down
2 changes: 2 additions & 0 deletions stratum/stratum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bool g_stratum_segwit = false;
int g_limit_txs_per_block = 0;

bool g_handle_haproxy_ips = false;
int g_socket_recv_timeout = 600;

bool g_debuglog_client;
bool g_debuglog_hash;
Expand Down Expand Up @@ -248,6 +249,7 @@ int main(int argc, char **argv)
g_stratum_reconnect = iniparser_getint(ini, "STRATUM:reconnect", true);
g_stratum_renting = iniparser_getint(ini, "STRATUM:renting", true);
g_handle_haproxy_ips = iniparser_getint(ini, "STRATUM:haproxy_ips", g_handle_haproxy_ips);
g_socket_recv_timeout = iniparser_getint(ini, "STRATUM:recv_timeout", 600);

g_max_shares = iniparser_getint(ini, "STRATUM:max_shares", g_max_shares);
g_limit_txs_per_block = iniparser_getint(ini, "STRATUM:max_txs_per_block", 0);
Expand Down
1 change: 1 addition & 0 deletions stratum/stratum.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern bool g_stratum_segwit;
extern int g_limit_txs_per_block;

extern bool g_handle_haproxy_ips;
extern int g_socket_recv_timeout;

extern bool g_debuglog_client;
extern bool g_debuglog_hash;
Expand Down

0 comments on commit c56969c

Please sign in to comment.