|
|
@ -209,7 +209,7 @@ static struct stratum_ctx stratum; |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_t applog_lock; |
|
|
|
pthread_mutex_t applog_lock; |
|
|
|
static pthread_mutex_t stats_lock; |
|
|
|
static pthread_mutex_t stats_lock; |
|
|
|
|
|
|
|
static uint8_t duplicate_shares = 0; |
|
|
|
static unsigned long accepted_count = 0L; |
|
|
|
static unsigned long accepted_count = 0L; |
|
|
|
static unsigned long rejected_count = 0L; |
|
|
|
static unsigned long rejected_count = 0L; |
|
|
|
static double *thr_hashrates; |
|
|
|
static double *thr_hashrates; |
|
|
@ -349,6 +349,13 @@ static struct work g_work; |
|
|
|
static time_t g_work_time; |
|
|
|
static time_t g_work_time; |
|
|
|
static pthread_mutex_t g_work_lock; |
|
|
|
static pthread_mutex_t g_work_lock; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void proper_exit(int reason) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
cuda_devicereset(); |
|
|
|
|
|
|
|
exit(reason); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool jobj_binary(const json_t *obj, const char *key, |
|
|
|
static bool jobj_binary(const json_t *obj, const char *key, |
|
|
|
void *buf, size_t buflen) |
|
|
|
void *buf, size_t buflen) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -423,8 +430,17 @@ static void share_result(int result, const char *reason) |
|
|
|
(result ? CL_GRN "yay!!!" : CL_RED "booooo") |
|
|
|
(result ? CL_GRN "yay!!!" : CL_RED "booooo") |
|
|
|
: (result ? "(yay!!!)" : "(booooo)")); |
|
|
|
: (result ? "(yay!!!)" : "(booooo)")); |
|
|
|
|
|
|
|
|
|
|
|
if (reason) |
|
|
|
if (reason) { |
|
|
|
|
|
|
|
if (!strcmp(reason, "Duplicate share")) { |
|
|
|
|
|
|
|
duplicate_shares++; |
|
|
|
|
|
|
|
if (duplicate_shares > 3) { |
|
|
|
|
|
|
|
// exit from app (until auto restart)
|
|
|
|
|
|
|
|
applog(LOG_WARNING, "Auto exit to prevent stratum bans: %s", reason); |
|
|
|
|
|
|
|
proper_exit(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
applog(LOG_WARNING, "reject reason: %s", reason); |
|
|
|
applog(LOG_WARNING, "reject reason: %s", reason); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool submit_upstream_work(CURL *curl, struct work *work) |
|
|
|
static bool submit_upstream_work(CURL *curl, struct work *work) |
|
|
@ -1253,7 +1269,7 @@ static void show_version_and_exit(void) |
|
|
|
PTW32_VERSION_STRING, |
|
|
|
PTW32_VERSION_STRING, |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
curl_version()); |
|
|
|
curl_version()); |
|
|
|
exit(0); |
|
|
|
proper_exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void show_usage_and_exit(int status) |
|
|
|
static void show_usage_and_exit(int status) |
|
|
@ -1262,7 +1278,7 @@ static void show_usage_and_exit(int status) |
|
|
|
fprintf(stderr, "Try `" PROGRAM_NAME " --help' for more information.\n"); |
|
|
|
fprintf(stderr, "Try `" PROGRAM_NAME " --help' for more information.\n"); |
|
|
|
else |
|
|
|
else |
|
|
|
printf(usage); |
|
|
|
printf(usage); |
|
|
|
exit(status); |
|
|
|
proper_exit(status); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void parse_arg (int key, char *arg) |
|
|
|
static void parse_arg (int key, char *arg) |
|
|
@ -1297,7 +1313,7 @@ static void parse_arg (int key, char *arg) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (!json_is_object(opt_config)) { |
|
|
|
if (!json_is_object(opt_config)) { |
|
|
|
applog(LOG_ERR, "JSON decode of %s failed", arg); |
|
|
|
applog(LOG_ERR, "JSON decode of %s failed", arg); |
|
|
|
exit(1); |
|
|
|
proper_exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -1440,7 +1456,7 @@ static void parse_arg (int key, char *arg) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1006: |
|
|
|
case 1006: |
|
|
|
print_hash_tests(); |
|
|
|
print_hash_tests(); |
|
|
|
exit(0); |
|
|
|
proper_exit(0); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1003: |
|
|
|
case 1003: |
|
|
|
want_longpoll = false; |
|
|
|
want_longpoll = false; |
|
|
@ -1462,7 +1478,7 @@ static void parse_arg (int key, char *arg) |
|
|
|
device_map[opt_n_threads++] = atoi(pch); |
|
|
|
device_map[opt_n_threads++] = atoi(pch); |
|
|
|
else { |
|
|
|
else { |
|
|
|
applog(LOG_ERR, "Non-existant CUDA device #%d specified in -d option", atoi(pch)); |
|
|
|
applog(LOG_ERR, "Non-existant CUDA device #%d specified in -d option", atoi(pch)); |
|
|
|
exit(1); |
|
|
|
proper_exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int device = cuda_finddevice(pch); |
|
|
|
int device = cuda_finddevice(pch); |
|
|
@ -1470,7 +1486,7 @@ static void parse_arg (int key, char *arg) |
|
|
|
device_map[opt_n_threads++] = device; |
|
|
|
device_map[opt_n_threads++] = device; |
|
|
|
else { |
|
|
|
else { |
|
|
|
applog(LOG_ERR, "Non-existant CUDA device '%s' specified in -d option", pch); |
|
|
|
applog(LOG_ERR, "Non-existant CUDA device '%s' specified in -d option", pch); |
|
|
|
exit(1); |
|
|
|
proper_exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
pch = strtok (NULL, ","); |
|
|
|
pch = strtok (NULL, ","); |
|
|
@ -1572,13 +1588,11 @@ static void signal_handler(int sig) |
|
|
|
case SIGINT: |
|
|
|
case SIGINT: |
|
|
|
signal(sig, SIG_IGN); |
|
|
|
signal(sig, SIG_IGN); |
|
|
|
applog(LOG_INFO, "SIGINT received, exiting"); |
|
|
|
applog(LOG_INFO, "SIGINT received, exiting"); |
|
|
|
cuda_devicereset(); |
|
|
|
proper_exit(0); |
|
|
|
exit(0); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case SIGTERM: |
|
|
|
case SIGTERM: |
|
|
|
applog(LOG_INFO, "SIGTERM received, exiting"); |
|
|
|
applog(LOG_INFO, "SIGTERM received, exiting"); |
|
|
|
cuda_devicereset(); |
|
|
|
proper_exit(0); |
|
|
|
exit(0); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1588,13 +1602,11 @@ BOOL WINAPI ConsoleHandler(DWORD dwType) |
|
|
|
switch (dwType) { |
|
|
|
switch (dwType) { |
|
|
|
case CTRL_C_EVENT: |
|
|
|
case CTRL_C_EVENT: |
|
|
|
applog(LOG_INFO, "CTRL_C_EVENT received, exiting"); |
|
|
|
applog(LOG_INFO, "CTRL_C_EVENT received, exiting"); |
|
|
|
cuda_devicereset(); |
|
|
|
proper_exit(0); |
|
|
|
exit(0); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case CTRL_BREAK_EVENT: |
|
|
|
case CTRL_BREAK_EVENT: |
|
|
|
applog(LOG_INFO, "CTRL_BREAK_EVENT received, exiting"); |
|
|
|
applog(LOG_INFO, "CTRL_BREAK_EVENT received, exiting"); |
|
|
|
cuda_devicereset(); |
|
|
|
proper_exit(0); |
|
|
|
exit(0); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1785,8 +1797,5 @@ int main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_INFO, "workio thread dead, exiting."); |
|
|
|
applog(LOG_INFO, "workio thread dead, exiting."); |
|
|
|
|
|
|
|
|
|
|
|
// nvprof requires this
|
|
|
|
|
|
|
|
cuda_devicereset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|