Ensure data cannot be sent to a TCP socket if the socket is in the process of closing.
Correct definition of StaticTask_t in the case that portUSE_MPU_WRAPPERS is set to 1.
prvTaskCheckFreeStackSpace() now returns configSTACK_DEPTH_TYPE to allow return values greater than max uint16_t value if required.
xStreamBufferSend() and xStreamBufferReceive() no longer clear task notification bits - clearing was unnecessary as only the task notification state is used.
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
index e40ce8d..10dc788 100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
@@ -2376,7 +2376,9 @@
 		{

 			xResult = -pdFREERTOS_ERRNO_ENOMEM;

 		}

-		else if( pxSocket->u.xTCP.ucTCPState == eCLOSED )

+		else if( ( pxSocket->u.xTCP.ucTCPState == eCLOSED ) ||

+				 ( pxSocket->u.xTCP.ucTCPState == eCLOSE_WAIT ) ||

+				 ( pxSocket->u.xTCP.ucTCPState == eCLOSING ) )

 		{

 			xResult = -pdFREERTOS_ERRNO_ENOTCONN;

 		}

diff --git a/FreeRTOS/Source/include/FreeRTOS.h b/FreeRTOS/Source/include/FreeRTOS.h
index f974c73..2b51f2b 100644
--- a/FreeRTOS/Source/include/FreeRTOS.h
+++ b/FreeRTOS/Source/include/FreeRTOS.h
@@ -1019,7 +1019,7 @@
 		uint32_t 		ulDummy18;

 		uint8_t 		ucDummy19;

 	#endif

-	#if( ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) || ( portUSING_MPU_WRAPPERS == 1 ) )

+	#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )

 		uint8_t			uxDummy20;

 	#endif

 

diff --git a/FreeRTOS/Source/include/task.h b/FreeRTOS/Source/include/task.h
index df7ce95..979cc4d 100644
--- a/FreeRTOS/Source/include/task.h
+++ b/FreeRTOS/Source/include/task.h
@@ -135,7 +135,7 @@
 	UBaseType_t uxBasePriority;		/* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex.  Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */

 	uint32_t ulRunTimeCounter;		/* The total run time allocated to the task so far, as defined by the run time stats clock.  See http://www.freertos.org/rtos-run-time-stats.html.  Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */

 	StackType_t *pxStackBase;		/* Points to the lowest address of the task's stack area. */

-	uint16_t usStackHighWaterMark;	/* The minimum amount of stack space that has remained for the task since the task was created.  The closer this value is to zero the closer the task has come to overflowing its stack. */

+	configSTACK_DEPTH_TYPE usStackHighWaterMark;	/* The minimum amount of stack space that has remained for the task since the task was created.  The closer this value is to zero the closer the task has come to overflowing its stack. */

 } TaskStatus_t;

 

 /* Possible return values for eTaskConfirmSleepModeStatus(). */

diff --git a/FreeRTOS/Source/stream_buffer.c b/FreeRTOS/Source/stream_buffer.c
index c0ef727..4061910 100644
--- a/FreeRTOS/Source/stream_buffer.c
+++ b/FreeRTOS/Source/stream_buffer.c
@@ -540,7 +540,7 @@
 			taskEXIT_CRITICAL();

 

 			traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer );

-			( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait );

+			( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );

 			pxStreamBuffer->xTaskWaitingToSend = NULL;

 

 		} while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE );

@@ -746,7 +746,7 @@
 		{

 			/* Wait for data to be available. */

 			traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer );

-			( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait );

+			( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );

 			pxStreamBuffer->xTaskWaitingToReceive = NULL;

 

 			/* Recheck the data available after blocking. */

diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c
index 7e4d9c5..268c17c 100644
--- a/FreeRTOS/Source/tasks.c
+++ b/FreeRTOS/Source/tasks.c
@@ -509,7 +509,7 @@
  */

 #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )

 

-	static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;

+	static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;

 

 #endif

 

@@ -846,6 +846,8 @@
 		uxPriority &= ~portPRIVILEGE_BIT;

 	#endif /* portUSING_MPU_WRAPPERS == 1 */

 

+	configASSERT( pcName );

+

 	/* Avoid dependency on memset() if it is not required. */

 	#if( tskSET_NEW_STACKS_TO_KNOWN_VALUE == 1 )

 	{

@@ -3625,7 +3627,7 @@
 

 #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )

 

-	static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )

+	static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )

 	{

 	uint32_t ulCount = 0U;

 

@@ -3637,7 +3639,7 @@
 

 		ulCount /= ( uint32_t ) sizeof( StackType_t ); /*lint !e961 Casting is not redundant on smaller architectures. */

 

-		return ( uint16_t ) ulCount;

+		return ( configSTACK_DEPTH_TYPE ) ulCount;

 	}

 

 #endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */