diff --git a/src/crypto/c_threads.h b/src/crypto/c_threads.h index b4f7736415c..3457738b38f 100644 --- a/src/crypto/c_threads.h +++ b/src/crypto/c_threads.h @@ -42,10 +42,11 @@ #define CTHR_RWLOCK_TRYLOCK_READ(x) TryAcquireSRWLockShared(&x) #define CTHR_THREAD_TYPE HANDLE -#define CTHR_THREAD_RTYPE void -#define CTHR_THREAD_RETURN return -#define CTHR_THREAD_CREATE(thr, func, arg) ((thr = (HANDLE)_beginthread(func, 0, arg)) != -1L) -#define CTHR_THREAD_JOIN(thr) WaitForSingleObject((HANDLE)thr, INFINITE) +#define CTHR_THREAD_RTYPE unsigned __stdcall +#define CTHR_THREAD_RETURN _endthreadex(0); return 0; +#define CTHR_THREAD_CREATE(thr, func, arg) ((thr = (HANDLE)_beginthreadex(0, 0, func, arg, 0, 0)) != 0L) +#define CTHR_THREAD_JOIN(thr) do { WaitForSingleObject(thr, INFINITE); CloseHandle(thr); } while(0) +#define CTHR_THREAD_CLOSE(thr) CloseHandle((HANDLE)thr); #else @@ -64,5 +65,6 @@ #define CTHR_THREAD_RETURN return NULL #define CTHR_THREAD_CREATE(thr, func, arg) (pthread_create(&thr, NULL, func, arg) == 0) #define CTHR_THREAD_JOIN(thr) pthread_join(thr, NULL) +#define CTHR_THREAD_CLOSE(thr) #endif diff --git a/src/crypto/rx-slow-hash.c b/src/crypto/rx-slow-hash.c index 14fb56e07bd..672144fcfcf 100644 --- a/src/crypto/rx-slow-hash.c +++ b/src/crypto/rx-slow-hash.c @@ -332,7 +332,7 @@ static void rx_init_dataset(size_t max_threads) { local_abort("Couldn't start RandomX seed thread"); } } - rx_seedthread(&si[n1]); + randomx_init_dataset(main_dataset, si[n1].si_cache, si[n1].si_start, si[n1].si_count); for (size_t i = 0; i < n1; ++i) CTHR_THREAD_JOIN(st[i]); CTHR_RWLOCK_UNLOCK_READ(main_cache_lock); @@ -402,6 +402,7 @@ void rx_set_main_seedhash(const char *seedhash, size_t max_dataset_init_threads) if (!CTHR_THREAD_CREATE(t, rx_set_main_seedhash_thread, info)) { local_abort("Couldn't start RandomX seed thread"); } + CTHR_THREAD_CLOSE(t); } void rx_slow_hash(const char *seedhash, const void *data, size_t length, char *result_hash) {