mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-10-09 23:53:04 -04:00
Merge ccbd282d5c into 8be86d4a24
This commit is contained in:
commit
fe8c9eba9e
1 changed files with 25 additions and 2 deletions
27
portable/ThirdParty/GCC/Posix/port.c
vendored
27
portable/ThirdParty/GCC/Posix/port.c
vendored
|
|
@ -139,7 +139,15 @@ static void prvThreadKeyDestructor( void * pvData )
|
|||
|
||||
static void prvInitThreadKey( void )
|
||||
{
|
||||
pthread_key_create( &xThreadKey, prvThreadKeyDestructor );
|
||||
int iRet;
|
||||
|
||||
iRet = pthread_key_create( &xThreadKey, prvThreadKeyDestructor );
|
||||
|
||||
if( iRet != 0 )
|
||||
{
|
||||
prvFatalError( "pthread_key_create", iRet );
|
||||
}
|
||||
|
||||
/* Destroy xThreadKey when the process exits. */
|
||||
atexit( prvDestroyThreadKey );
|
||||
}
|
||||
|
|
@ -148,6 +156,7 @@ static void prvInitThreadKey( void )
|
|||
static void prvMarkAsFreeRTOSThread( void )
|
||||
{
|
||||
uint8_t * pucThreadData = NULL;
|
||||
int iRet;
|
||||
|
||||
( void ) pthread_once( &hThreadKeyOnce, prvInitThreadKey );
|
||||
|
||||
|
|
@ -156,7 +165,21 @@ static void prvMarkAsFreeRTOSThread( void )
|
|||
|
||||
*pucThreadData = 1;
|
||||
|
||||
pthread_setspecific( xThreadKey, pucThreadData );
|
||||
iRet = pthread_setspecific( xThreadKey, pucThreadData );
|
||||
|
||||
if( iRet != 0 )
|
||||
{
|
||||
/* The marker was not stored, so the TLS destructor would never run
|
||||
* for it -- free it here instead of leaking it, then treat the
|
||||
* failure as fatal via prvFatalError(), consistent with how this
|
||||
* port already handles other unexpected pthread call failures
|
||||
* (see pthread_create()/sigaction() above). This function returns
|
||||
* void, so there is no way to propagate the failure to the caller;
|
||||
* continuing would leave the thread unmarked and silently
|
||||
* misclassified by prvIsFreeRTOSThread(). */
|
||||
free( pucThreadData );
|
||||
prvFatalError( "pthread_setspecific", iRet );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue