mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(freertos): Fixed SMP race condition in xStreamBufferSend()
This commit fixes a race condition in dual-core SMP mode where in the xStreamBufferSend() makes the xTaskWaitingToSend NULL but it may have already been evaluated to not be NULL by xStreamBufferReceive() running on another core and eventually leading to a crash in tasks.c.
This commit is contained in:
parent
795e2bbae1
commit
6571b492f2
@ -680,7 +680,18 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
|
||||
|
||||
traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer );
|
||||
( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
|
||||
pxStreamBuffer->xTaskWaitingToSend = NULL;
|
||||
/* In SMP mode, the task may have been woken and scheduled on
|
||||
* another core. Hence, we must clear the xTaskWaitingToSend
|
||||
* handle in a critical section. */
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
taskENTER_CRITICAL();
|
||||
#endif /* configNUMBER_OF_CORES > 1 */
|
||||
{
|
||||
pxStreamBuffer->xTaskWaitingToSend = NULL;
|
||||
}
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
taskEXIT_CRITICAL();
|
||||
#endif /* configNUMBER_OF_CORES > 1 */
|
||||
} while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE );
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user