mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-10 15:21:01 +02:00
Merge branch 'fix/freertos_race_cond_in_stream_buffers_v5.1' into 'release/v5.1'
fix(freertos): Fixed SMP race condition in stream_buffers.c (v5.1) See merge request espressif/esp-idf!34227
This commit is contained in:
@@ -855,7 +855,19 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
|
|||||||
/* Wait for data to be available. */
|
/* Wait for data to be available. */
|
||||||
traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer );
|
traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer );
|
||||||
( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
|
( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
|
||||||
pxStreamBuffer->xTaskWaitingToReceive = NULL;
|
|
||||||
|
/* In SMP mode, the task may have been woken and scheduled on
|
||||||
|
* another core. Hence, we must clear the xTaskWaitingToReceive
|
||||||
|
* handle in a critical section. */
|
||||||
|
#if ( configNUM_CORES > 1 )
|
||||||
|
taskENTER_CRITICAL( &( pxStreamBuffer->xStreamBufferLock ) );
|
||||||
|
#endif /* configNUMBER_OF_CORES > 1 */
|
||||||
|
{
|
||||||
|
pxStreamBuffer->xTaskWaitingToReceive = NULL;
|
||||||
|
}
|
||||||
|
#if ( configNUM_CORES > 1 )
|
||||||
|
taskEXIT_CRITICAL( &( pxStreamBuffer->xStreamBufferLock ) );
|
||||||
|
#endif /* configNUMBER_OF_CORES > 1 */
|
||||||
|
|
||||||
/* Recheck the data available after blocking. */
|
/* Recheck the data available after blocking. */
|
||||||
xBytesAvailable = prvBytesInBuffer( pxStreamBuffer );
|
xBytesAvailable = prvBytesInBuffer( pxStreamBuffer );
|
||||||
|
Reference in New Issue
Block a user