@@ -137,6 +137,7 @@ static const char *algo_names[] = {
137137
138138bool opt_debug = false;
139139bool opt_protocol = false;
140+ static bool opt_keepalive = false ;
140141static bool opt_benchmark = false;
141142bool opt_redirect = true;
142143bool want_longpoll = true;
@@ -207,6 +208,7 @@ Options:\n\
207208 --cert=FILE certificate for mining server using SSL\n\
208209 -x, --proxy=[PROTOCOL://]HOST[:PORT] connect through a proxy\n\
209210 -t, --threads=N number of miner threads (default: number of processors)\n\
211+ -k, --keepalive Send keepalived for prevent timeout (need pool support features)\n\
210212 -r, --retries=N number of times to retry if a network call fails\n\
211213 (default: retry indefinitely)\n\
212214 -R, --retry-pause=N time to pause between retries, in seconds (default: 30)\n\
@@ -241,7 +243,7 @@ static char const short_options[] =
241243#ifdef HAVE_SYSLOG_H
242244 "S"
243245#endif
244- "a:c:Dhp:Px:qr :R:s:t:T:o:u:O:V" ;
246+ "a:c:Dhp:Px:kqr :R:s:t:T:o:u:O:V" ;
245247
246248static struct option const options [] = {
247249 { "algo" , 1 , NULL , 'a' },
@@ -253,6 +255,7 @@ static struct option const options[] = {
253255 { "config" , 1 , NULL , 'c' },
254256 { "debug" , 0 , NULL , 'D' },
255257 { "help" , 0 , NULL , 'h' },
258+ { "keepalive" , 0 , NULL ,'k' },
256259 { "no-longpoll" , 0 , NULL , 1003 },
257260 { "no-redirect" , 0 , NULL , 1009 },
258261 { "no-stratum" , 0 , NULL , 1007 },
@@ -1047,7 +1050,6 @@ static void *miner_thread(void *userdata) {
10471050 thr_id % num_processors);
10481051 affine_to_cpu(thr_id, thr_id % num_processors);
10491052 }*/
1050-
10511053 persistentctx = persistentctxs [thr_id ];
10521054 if (!persistentctx && opt_algo == ALGO_CRYPTONIGHT )
10531055 {
@@ -1328,8 +1330,12 @@ static bool stratum_handle_response(char *buf) {
13281330
13291331 if (jsonrpc_2 ) {
13301332 json_t * status = json_object_get (res_val , "status" );
1333+ const char * s = json_string_value (status );
1334+ if ( !strcmp (s , "KEEPALIVED" ) ) {
1335+ applog (LOG_INFO , "Keepalived receveid" );
1336+ goto out ;
1337+ }
13311338 if (status ) {
1332- const char * s = json_string_value (status );
13331339 valid = !strcmp (s , "OK" ) && json_is_null (err_val );
13341340 } else {
13351341 valid = json_is_null (err_val );
@@ -1405,11 +1411,14 @@ static void *stratum_thread(void *userdata) {
14051411 }
14061412 }
14071413 }
1408-
1409- if (!stratum_socket_full (& stratum , 600 )) {
1410- applog (LOG_ERR , "Stratum connection timed out" );
1411- s = NULL ;
1412- } else
1414+ if ( opt_keepalive && !stratum_socket_full (& stratum , 90 )) {
1415+ applog (LOG_INFO , "Keepalived send...." );
1416+ stratum_keepalived (& stratum ,rpc2_id );
1417+ }
1418+ if (!stratum_socket_full (& stratum , 300 )) {
1419+ applog (LOG_ERR , "Stratum connection timed out" );
1420+ s = NULL ;
1421+ } else
14131422 s = stratum_recv_line (& stratum );
14141423 if (!s ) {
14151424 stratum_disconnect (& stratum );
0 commit comments