mirror of
https://github.com/GOSTSec/vanitygen
synced 2025-02-07 12:24:20 +00:00
Clean up timing statistics on thread shutdown.
This commit is contained in:
parent
a4398961a6
commit
217351c30b
@ -2189,6 +2189,7 @@ l_rekey:
|
||||
vg_ocl_free_args(vocp);
|
||||
vocp->voc_halt = 0;
|
||||
vocp->voc_ocl_slot = -1;
|
||||
vg_context_thread_exit(vcp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
31
pattern.c
31
pattern.c
@ -138,11 +138,11 @@ typedef struct _timing_info_s {
|
||||
int ti_hist_last;
|
||||
} timing_info_t;
|
||||
|
||||
static pthread_mutex_t timing_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
int
|
||||
vg_output_timing(vg_context_t *vcp, int cycle, struct timeval *last)
|
||||
{
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
pthread_t me;
|
||||
struct timeval tvnow, tv;
|
||||
timing_info_t *tip, *mytip;
|
||||
@ -158,7 +158,7 @@ vg_output_timing(vg_context_t *vcp, int cycle, struct timeval *last)
|
||||
mytime = 1;
|
||||
rate = 0;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_mutex_lock(&timing_mutex);
|
||||
me = pthread_self();
|
||||
for (tip = vcp->vc_timing_head, mytip = NULL;
|
||||
tip != NULL; tip = tip->ti_next) {
|
||||
@ -207,17 +207,38 @@ vg_output_timing(vg_context_t *vcp, int cycle, struct timeval *last)
|
||||
vcp->vc_timing_sincelast += cycle;
|
||||
|
||||
if (mytip != vcp->vc_timing_head) {
|
||||
pthread_mutex_unlock(&mutex);
|
||||
pthread_mutex_unlock(&timing_mutex);
|
||||
return myrate;
|
||||
}
|
||||
total = vcp->vc_timing_total;
|
||||
sincelast = vcp->vc_timing_sincelast;
|
||||
pthread_mutex_unlock(&mutex);
|
||||
pthread_mutex_unlock(&timing_mutex);
|
||||
|
||||
vcp->vc_output_timing(vcp, sincelast, rate, total);
|
||||
return myrate;
|
||||
}
|
||||
|
||||
void
|
||||
vg_context_thread_exit(vg_context_t *vcp)
|
||||
{
|
||||
timing_info_t *tip, **ptip;
|
||||
pthread_t me;
|
||||
|
||||
pthread_mutex_lock(&timing_mutex);
|
||||
me = pthread_self();
|
||||
for (ptip = &vcp->vc_timing_head, tip = *ptip;
|
||||
tip != NULL;
|
||||
ptip = &tip->ti_next, tip = *ptip) {
|
||||
if (!pthread_equal(tip->ti_thread, me))
|
||||
continue;
|
||||
*ptip = tip->ti_next;
|
||||
free(tip);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&timing_mutex);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
vg_timing_info_free(vg_context_t *vcp)
|
||||
{
|
||||
|
@ -122,6 +122,7 @@ extern int vg_context_add_patterns(vg_context_t *vcp,
|
||||
const char ** const patterns, int npatterns);
|
||||
extern void vg_context_clear_all_patterns(vg_context_t *vcp);
|
||||
extern int vg_context_hash160_sort(vg_context_t *vcp, void *buf);
|
||||
extern void vg_context_thread_exit(vg_context_t *vcp);
|
||||
|
||||
|
||||
extern vg_context_t *vg_prefix_context_new(int addrtype, int privtype,
|
||||
|
@ -392,6 +392,7 @@ vg_thread_loop(void *arg)
|
||||
|
||||
out:
|
||||
vg_thread_context_del(&ctx);
|
||||
vg_context_thread_exit(vcp);
|
||||
|
||||
for (i = 0; i < ptarraysize; i++)
|
||||
if (ppnt[i])
|
||||
|
Loading…
x
Reference in New Issue
Block a user