mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
API lock access to some summary statistics (and copy them)
This commit is contained in:
parent
16637ac91e
commit
a67e96c3e4
37
api.c
37
api.c
@ -1879,6 +1879,9 @@ static void summary(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, boo
|
|||||||
algo = (char *)NULLSTR;
|
algo = (char *)NULLSTR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// stop hashmeter() changing some while copying
|
||||||
|
mutex_lock(&hash_lock);
|
||||||
|
|
||||||
utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
|
utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
|
||||||
mhs = total_mhashes_done / total_secs;
|
mhs = total_mhashes_done / total_secs;
|
||||||
work_utility = total_diff1 / ( total_secs ? total_secs : 1 ) * 60;
|
work_utility = total_diff1 / ( total_secs ? total_secs : 1 ) * 60;
|
||||||
@ -1888,28 +1891,30 @@ static void summary(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, boo
|
|||||||
: "%s" _SUMMARY ",",
|
: "%s" _SUMMARY ",",
|
||||||
message(MSG_SUMM, 0, NULL, isjson));
|
message(MSG_SUMM, 0, NULL, isjson));
|
||||||
|
|
||||||
root = api_add_elapsed(root, "Elapsed", &(total_secs), false);
|
root = api_add_elapsed(root, "Elapsed", &(total_secs), true);
|
||||||
#ifdef WANT_CPUMINE
|
#ifdef WANT_CPUMINE
|
||||||
root = api_add_string(root, "Algorithm", algo, false);
|
root = api_add_string(root, "Algorithm", algo, false);
|
||||||
#endif
|
#endif
|
||||||
root = api_add_mhs(root, "MHS av", &(mhs), false);
|
root = api_add_mhs(root, "MHS av", &(mhs), false);
|
||||||
root = api_add_uint(root, "Found Blocks", &(found_blocks), false);
|
root = api_add_uint(root, "Found Blocks", &(found_blocks), true);
|
||||||
root = api_add_int(root, "Getworks", &(total_getworks), false);
|
root = api_add_int(root, "Getworks", &(total_getworks), true);
|
||||||
root = api_add_int(root, "Accepted", &(total_accepted), false);
|
root = api_add_int(root, "Accepted", &(total_accepted), true);
|
||||||
root = api_add_int(root, "Rejected", &(total_rejected), false);
|
root = api_add_int(root, "Rejected", &(total_rejected), true);
|
||||||
root = api_add_int(root, "Hardware Errors", &(hw_errors), false);
|
root = api_add_int(root, "Hardware Errors", &(hw_errors), true);
|
||||||
root = api_add_utility(root, "Utility", &(utility), false);
|
root = api_add_utility(root, "Utility", &(utility), false);
|
||||||
root = api_add_int(root, "Discarded", &(total_discarded), false);
|
root = api_add_int(root, "Discarded", &(total_discarded), true);
|
||||||
root = api_add_int(root, "Stale", &(total_stale), false);
|
root = api_add_int(root, "Stale", &(total_stale), true);
|
||||||
root = api_add_uint(root, "Get Failures", &(total_go), false);
|
root = api_add_uint(root, "Get Failures", &(total_go), true);
|
||||||
root = api_add_uint(root, "Local Work", &(local_work), false);
|
root = api_add_uint(root, "Local Work", &(local_work), true);
|
||||||
root = api_add_uint(root, "Remote Failures", &(total_ro), false);
|
root = api_add_uint(root, "Remote Failures", &(total_ro), true);
|
||||||
root = api_add_uint(root, "Network Blocks", &(new_blocks), false);
|
root = api_add_uint(root, "Network Blocks", &(new_blocks), true);
|
||||||
root = api_add_mhtotal(root, "Total MH", &(total_mhashes_done), false);
|
root = api_add_mhtotal(root, "Total MH", &(total_mhashes_done), true);
|
||||||
root = api_add_utility(root, "Work Utility", &(work_utility), false);
|
root = api_add_utility(root, "Work Utility", &(work_utility), false);
|
||||||
root = api_add_diff(root, "Difficulty Accepted", &(total_diff_accepted), false);
|
root = api_add_diff(root, "Difficulty Accepted", &(total_diff_accepted), true);
|
||||||
root = api_add_diff(root, "Difficulty Rejected", &(total_diff_rejected), false);
|
root = api_add_diff(root, "Difficulty Rejected", &(total_diff_rejected), true);
|
||||||
root = api_add_diff(root, "Difficulty Stale", &(total_diff_stale), false);
|
root = api_add_diff(root, "Difficulty Stale", &(total_diff_stale), true);
|
||||||
|
|
||||||
|
mutex_unlock(&hash_lock);
|
||||||
|
|
||||||
root = print_data(root, buf, isjson);
|
root = print_data(root, buf, isjson);
|
||||||
if (isjson)
|
if (isjson)
|
||||||
|
@ -174,7 +174,7 @@ static int total_threads;
|
|||||||
pthread_mutex_t cgusb_lock;
|
pthread_mutex_t cgusb_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static pthread_mutex_t hash_lock;
|
pthread_mutex_t hash_lock;
|
||||||
static pthread_mutex_t qd_lock;
|
static pthread_mutex_t qd_lock;
|
||||||
static pthread_mutex_t *stgd_lock;
|
static pthread_mutex_t *stgd_lock;
|
||||||
pthread_mutex_t console_lock;
|
pthread_mutex_t console_lock;
|
||||||
|
1
miner.h
1
miner.h
@ -705,6 +705,7 @@ extern int opt_expiry;
|
|||||||
extern pthread_mutex_t cgusb_lock;
|
extern pthread_mutex_t cgusb_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern pthread_mutex_t hash_lock;
|
||||||
extern pthread_mutex_t console_lock;
|
extern pthread_mutex_t console_lock;
|
||||||
extern pthread_mutex_t ch_lock;
|
extern pthread_mutex_t ch_lock;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user