diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-25 19:08:52 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-26 09:23:02 +0100 |
commit | 1ac4a85ebf0cd0e788c2d5374c635087c33de0bf (patch) | |
tree | 55e5da6a482cc00eb616c6d01b9f2732900ab2b4 /cpukit/include | |
parent | libtest: Print SHA256 hash in base64url (diff) | |
download | rtems-1ac4a85ebf0cd0e788c2d5374c635087c33de0bf.tar.bz2 |
score: Fix thread initialization
Close the thread object if a thread create extension fails. Also call
the delete extension to avoid resource leaks in early extensions if a
late extension fails.
Close #4270.
Diffstat (limited to 'cpukit/include')
-rw-r--r-- | cpukit/include/rtems/posix/pthreadimpl.h | 7 | ||||
-rw-r--r-- | cpukit/include/rtems/score/threadimpl.h | 22 |
2 files changed, 19 insertions, 10 deletions
diff --git a/cpukit/include/rtems/posix/pthreadimpl.h b/cpukit/include/rtems/posix/pthreadimpl.h index 74e46e4d92..52d462ab6f 100644 --- a/cpukit/include/rtems/posix/pthreadimpl.h +++ b/cpukit/include/rtems/posix/pthreadimpl.h @@ -107,13 +107,6 @@ RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void) _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects ); } -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free ( - Thread_Control *the_pthread -) -{ - _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object ); -} - /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h index 0c7df47f36..1e7d58609f 100644 --- a/cpukit/include/rtems/score/threadimpl.h +++ b/cpukit/include/rtems/score/threadimpl.h @@ -201,16 +201,32 @@ typedef struct { * @param the_thread The thread to initialize. * @param config The configuration of the thread to initialize. * - * @retval true The thread initialization was successful. - * @retval false The thread initialization failed. + * @retval STATUS_SUCCESSFUL The thread initialization was successful. + * + * @retval STATUS_UNSATISFIED The thread initialization failed. */ -bool _Thread_Initialize( +Status_Control _Thread_Initialize( Thread_Information *information, Thread_Control *the_thread, const Thread_Configuration *config ); /** + * @brief Frees the thread. + * + * This routine invokes the thread delete extensions and frees all resources + * associated with the thread. Afterwards the thread object is closed. + * + * @param[in, out] information is the thread information. + * + * @param[in, out] the_thread is the thread to free. + */ +void _Thread_Free( + Thread_Information *information, + Thread_Control *the_thread +); + +/** * @brief Starts the specified thread. * * If the thread is not in the dormant state, the routine returns with a value |