@@ -137,6 +137,7 @@ static const char *algo_names[] = {
137
137
138
138
bool opt_debug = false;
139
139
bool opt_protocol = false;
140
+ static bool opt_keepalive = false ;
140
141
static bool opt_benchmark = false;
141
142
bool opt_redirect = true;
142
143
bool want_longpoll = true;
@@ -207,6 +208,7 @@ Options:\n\
207
208
--cert=FILE certificate for mining server using SSL\n\
208
209
-x, --proxy=[PROTOCOL://]HOST[:PORT] connect through a proxy\n\
209
210
-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\
210
212
-r, --retries=N number of times to retry if a network call fails\n\
211
213
(default: retry indefinitely)\n\
212
214
-R, --retry-pause=N time to pause between retries, in seconds (default: 30)\n\
@@ -241,7 +243,7 @@ static char const short_options[] =
241
243
#ifdef HAVE_SYSLOG_H
242
244
"S"
243
245
#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" ;
245
247
246
248
static struct option const options [] = {
247
249
{ "algo" , 1 , NULL , 'a' },
@@ -253,6 +255,7 @@ static struct option const options[] = {
253
255
{ "config" , 1 , NULL , 'c' },
254
256
{ "debug" , 0 , NULL , 'D' },
255
257
{ "help" , 0 , NULL , 'h' },
258
+ { "keepalive" , 0 , NULL ,'k' },
256
259
{ "no-longpoll" , 0 , NULL , 1003 },
257
260
{ "no-redirect" , 0 , NULL , 1009 },
258
261
{ "no-stratum" , 0 , NULL , 1007 },
@@ -1047,7 +1050,6 @@ static void *miner_thread(void *userdata) {
1047
1050
thr_id % num_processors);
1048
1051
affine_to_cpu(thr_id, thr_id % num_processors);
1049
1052
}*/
1050
-
1051
1053
persistentctx = persistentctxs [thr_id ];
1052
1054
if (!persistentctx && opt_algo == ALGO_CRYPTONIGHT )
1053
1055
{
@@ -1328,8 +1330,12 @@ static bool stratum_handle_response(char *buf) {
1328
1330
1329
1331
if (jsonrpc_2 ) {
1330
1332
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
+ }
1331
1338
if (status ) {
1332
- const char * s = json_string_value (status );
1333
1339
valid = !strcmp (s , "OK" ) && json_is_null (err_val );
1334
1340
} else {
1335
1341
valid = json_is_null (err_val );
@@ -1405,11 +1411,14 @@ static void *stratum_thread(void *userdata) {
1405
1411
}
1406
1412
}
1407
1413
}
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
1413
1422
s = stratum_recv_line (& stratum );
1414
1423
if (!s ) {
1415
1424
stratum_disconnect (& stratum );
0 commit comments