diff options
author | Čestmír Kalina <ckalina@redhat.com> | 2022-10-21 19:49:21 +0200 |
---|---|---|
committer | Čestmír Kalina <ckalina@redhat.com> | 2022-10-21 19:57:16 +0200 |
commit | 4f32754f79d697e3af78d821296fd02fbba6e186 (patch) | |
tree | 5dbd9b14b43425fbb1b3894f4c3ff3b37b228e39 /crypto/thread | |
parent | 3a09dfb4f9aace93d2c20d6d1b4968cc583884d6 (diff) |
crypto: thread: remove ossl_crypto_thread_native_terminate
Signed-off-by: Čestmír Kalina <ckalina@redhat.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19473)
Diffstat (limited to 'crypto/thread')
-rw-r--r-- | crypto/thread/arch.c | 9 | ||||
-rw-r--r-- | crypto/thread/arch/thread_none.c | 5 | ||||
-rw-r--r-- | crypto/thread/arch/thread_posix.c | 46 | ||||
-rw-r--r-- | crypto/thread/arch/thread_win.c | 43 |
4 files changed, 1 insertions, 102 deletions
diff --git a/crypto/thread/arch.c b/crypto/thread/arch.c index 72fddf5f84..3dddcb10a8 100644 --- a/crypto/thread/arch.c +++ b/crypto/thread/arch.c @@ -54,16 +54,10 @@ int ossl_crypto_thread_native_join(CRYPTO_THREAD *thread, CRYPTO_THREAD_RETVAL * return 0; ossl_crypto_mutex_lock(thread->statelock); - req_state_mask = CRYPTO_THREAD_TERMINATED | CRYPTO_THREAD_FINISHED \ - | CRYPTO_THREAD_JOINED; + req_state_mask = CRYPTO_THREAD_FINISHED | CRYPTO_THREAD_JOINED; while (!CRYPTO_THREAD_GET_STATE(thread, req_state_mask)) ossl_crypto_condvar_wait(thread->condvar, thread->statelock); - if (CRYPTO_THREAD_GET_STATE(thread, CRYPTO_THREAD_TERMINATED)) { - ossl_crypto_mutex_unlock(thread->statelock); - return 0; - } - if (CRYPTO_THREAD_GET_STATE(thread, CRYPTO_THREAD_JOINED)) goto pass; @@ -121,7 +115,6 @@ int ossl_crypto_thread_native_clean(CRYPTO_THREAD *handle) req_state_mask = 0; req_state_mask |= CRYPTO_THREAD_FINISHED; - req_state_mask |= CRYPTO_THREAD_TERMINATED; req_state_mask |= CRYPTO_THREAD_JOINED; ossl_crypto_mutex_lock(handle->statelock); diff --git a/crypto/thread/arch/thread_none.c b/crypto/thread/arch/thread_none.c index 1da736a7fb..431a9b6a35 100644 --- a/crypto/thread/arch/thread_none.c +++ b/crypto/thread/arch/thread_none.c @@ -21,11 +21,6 @@ int ossl_crypto_thread_native_perform_join(CRYPTO_THREAD *thread, CRYPTO_THREAD_ return 0; } -int ossl_crypto_thread_native_terminate(CRYPTO_THREAD *thread) -{ - return 0; -} - int ossl_crypto_thread_native_exit(void) { return 0; diff --git a/crypto/thread/arch/thread_posix.c b/crypto/thread/arch/thread_posix.c index 0504ac9f81..b737a5e788 100644 --- a/crypto/thread/arch/thread_posix.c +++ b/crypto/thread/arch/thread_posix.c @@ -85,52 +85,6 @@ int ossl_crypto_thread_native_perform_join(CRYPTO_THREAD *thread, CRYPTO_THREAD_ return 1; } -int ossl_crypto_thread_native_terminate(CRYPTO_THREAD *thread) -{ - void *res; - uint64_t mask; - pthread_t *handle; - - mask = CRYPTO_THREAD_FINISHED; - mask |= CRYPTO_THREAD_TERMINATED; - mask |= CRYPTO_THREAD_JOINED; - - if (thread == NULL) - return 0; - - ossl_crypto_mutex_lock(thread->statelock); - if (thread->handle == NULL || CRYPTO_THREAD_GET_STATE(thread, mask)) - goto terminated; - /* Do not fail when there's a join in progress. Do not block. */ - if (CRYPTO_THREAD_GET_STATE(thread, CRYPTO_THREAD_JOIN_AWAIT)) - goto fail; - ossl_crypto_mutex_unlock(thread->statelock); - - handle = thread->handle; - if (pthread_cancel(*handle) != 0) { - ossl_crypto_mutex_lock(thread->statelock); - goto fail; - } - if (pthread_join(*handle, &res) != 0) - return 0; - if (res != PTHREAD_CANCELED) - return 0; - - thread->handle = NULL; - OPENSSL_free(handle); - - ossl_crypto_mutex_lock(thread->statelock); -terminated: - CRYPTO_THREAD_UNSET_ERROR(thread, CRYPTO_THREAD_TERMINATED); - CRYPTO_THREAD_SET_STATE(thread, CRYPTO_THREAD_TERMINATED); - ossl_crypto_mutex_unlock(thread->statelock); - return 1; -fail: - CRYPTO_THREAD_SET_ERROR(thread, CRYPTO_THREAD_TERMINATED); - ossl_crypto_mutex_unlock(thread->statelock); - return 0; -} - int ossl_crypto_thread_native_exit(void) { pthread_exit(NULL); diff --git a/crypto/thread/arch/thread_win.c b/crypto/thread/arch/thread_win.c index 7b63712d5b..b4c0500936 100644 --- a/crypto/thread/arch/thread_win.c +++ b/crypto/thread/arch/thread_win.c @@ -83,49 +83,6 @@ int ossl_crypto_thread_native_perform_join(CRYPTO_THREAD *thread, CRYPTO_THREAD_ return 1; } -int ossl_crypto_thread_native_terminate(CRYPTO_THREAD *thread) -{ - uint64_t mask; - HANDLE *handle; - - mask = CRYPTO_THREAD_FINISHED; - mask |= CRYPTO_THREAD_TERMINATED; - mask |= CRYPTO_THREAD_JOINED; - - if (thread == NULL) - return 1; - - ossl_crypto_mutex_lock(thread->statelock); - if (thread->handle == NULL || CRYPTO_THREAD_GET_STATE(thread, mask)) - goto terminated; - ossl_crypto_mutex_unlock(thread->statelock); - - handle = thread->handle; - if (WaitForSingleObject(*handle, 0) != WAIT_OBJECT_0) { - if (TerminateThread(*handle, STILL_ACTIVE) == 0) { - ossl_crypto_mutex_lock(thread->statelock); - CRYPTO_THREAD_SET_ERROR(thread, CRYPTO_THREAD_TERMINATED); - ossl_crypto_mutex_unlock(thread->statelock); - return 0; - } - } - - if (CloseHandle(*handle) == 0) { - CRYPTO_THREAD_SET_ERROR(thread, CRYPTO_THREAD_TERMINATED); - return 0; - } - - thread->handle = NULL; - OPENSSL_free(handle); - - ossl_crypto_mutex_lock(thread->statelock); -terminated: - CRYPTO_THREAD_UNSET_ERROR(thread, CRYPTO_THREAD_TERMINATED); - CRYPTO_THREAD_SET_STATE(thread, CRYPTO_THREAD_TERMINATED); - ossl_crypto_mutex_unlock(thread->statelock); - return 1; -} - int ossl_crypto_thread_native_exit(void) { _endthreadex(0); |