From 4c9b90bf4eca1f4dce9761c7cccbc083ff6a7acb Mon Sep 17 00:00:00 2001 From: ryan-doan <82603138+ryan-doan@users.noreply.github.com> Date: Sun, 7 May 2023 20:09:33 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9BAdd=20mutex=20control=20for=20print?= =?UTF-8?q?f=20and=20cout=20(#570)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial commit * Added back a missing taskEXIT_CRITICAL() --- src/rtos/stream_buffer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rtos/stream_buffer.c b/src/rtos/stream_buffer.c index e9cd12d5f..504f1ac85 100644 --- a/src/rtos/stream_buffer.c +++ b/src/rtos/stream_buffer.c @@ -559,7 +559,9 @@ TimeOut_t xTimeOut; mtCOVERAGE_TEST_MARKER(); } + taskENTER_CRITICAL(); xReturn = prvWriteMessageToBuffer( pxStreamBuffer, pvTxData, xDataLengthBytes, xSpace, xRequiredSpace ); + taskEXIT_CRITICAL(); if( xReturn > ( size_t ) 0 ) { @@ -666,7 +668,9 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer, into the buffer. Start by writing the length of the data, the data itself will be written later in this function. */ xShouldWrite = pdTRUE; + taskENTER_CRITICAL(); ( void ) prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( xDataLengthBytes ), sbBYTES_TO_STORE_MESSAGE_LENGTH ); + taskEXIT_CRITICAL(); } else { @@ -677,7 +681,9 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer, if( xShouldWrite != pdFALSE ) { /* Writes the data itself. */ + taskENTER_CRITICAL(); xReturn = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) pvTxData, xDataLengthBytes ); /*lint !e9079 Storage buffer is implemented as uint8_t for ease of sizing, alighment and access. */ + taskEXIT_CRITICAL(); } else { @@ -864,7 +870,9 @@ size_t xOriginalTail, xReceivedLength, xNextMessageLength; returned to its prior state if the length of the message is too large for the provided buffer. */ xOriginalTail = pxStreamBuffer->xTail; + taskENTER_CRITICAL(); ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable ); + taskEXIT_CRITICAL(); /* Reduce the number of bytes available by the number of bytes just read out. */ @@ -893,7 +901,9 @@ size_t xOriginalTail, xReceivedLength, xNextMessageLength; } /* Read the actual data. */ + taskENTER_CRITICAL(); xReceivedLength = prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) pvRxData, xNextMessageLength, xBytesAvailable ); /*lint !e9079 Data storage area is implemented as uint8_t array for ease of sizing, indexing and alignment. */ + taskEXIT_CRITICAL(); return xReceivedLength; }