Added vTaskDelete and fixed memory leak

This commit is contained in:
Alexei 2023-02-20 01:50:15 +07:00
parent a95e8db5a3
commit 4539074520
2 changed files with 24 additions and 4 deletions

View File

@ -157,7 +157,8 @@ Socket_t xListeningSocket, xConnectedSocket;
socklen_t xSize = sizeof( xClient );
static const TickType_t xReceiveTimeOut = portMAX_DELAY;
const BaseType_t xBacklog = 20;
TaskHandle_t prvServerConnectionInstance_Handle = NULL;
#if( ipconfigUSE_TCP_WIN == 1 )
WinProperties_t xWinProps;
@ -201,7 +202,10 @@ const BaseType_t xBacklog = 20;
xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient, &xSize );
configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
/* Spawn a task to handle the connection. */
xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY + 1, NULL );
if (prvServerConnectionInstance_Handle)
vTaskDelete( prvServerConnectionInstance_Handle );
xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY + 1, &prvServerConnectionInstance_Handle );
}
}
/*-----------------------------------------------------------*/

View File

@ -157,9 +157,25 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>206</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134220272</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\DemoTasks\SimpleTCPEchoServer.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\Test_project_for_GD32107C_EVAL\DemoTasks/SimpleTCPEchoServer.c\206</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>511</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134230234</Address>
<Address>134230238</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -171,7 +187,7 @@
<Expression>\\Test_project_for_GD32107C_EVAL\FreeRTOS/source/FreeRTOS_DHCP.c\511</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Number>2</Number>
<Type>0</Type>
<LineNumber>6</LineNumber>
<EnabledFlag>1</EnabledFlag>