Merge branch 'fix/freertos_race_cond_in_stream_buffers_send_v5.1' into 'release/v5.1'

fix(freertos): Fixed SMP race condition in xStreamBufferSend() (v5.1)

See merge request espressif/esp-idf!34337
This commit is contained in:
Marius Vikhammer
2024-10-31 09:46:38 +08:00

View File

@@ -650,7 +650,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( &( pxStreamBuffer->xStreamBufferLock ) );
#endif /* configNUMBER_OF_CORES > 1 */
{
pxStreamBuffer->xTaskWaitingToSend = NULL;
}
#if ( configNUMBER_OF_CORES > 1 )
taskEXIT_CRITICAL( &( pxStreamBuffer->xStreamBufferLock ) );
#endif /* configNUMBER_OF_CORES > 1 */
} while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE );
}
else