Skip to content

Commit 1cc911f

Browse files
committed
Bugfix for Socket lifetime issues and potentially multiple close sockets causing DataAbort interrupts. (#570)
1 parent 9bd9d28 commit 1cc911f

File tree

7 files changed

+172
-90
lines changed

7 files changed

+172
-90
lines changed

source/FreeRTOS_DHCP.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@
596596
{
597597
/* This modules runs from the IP-task. Use the internal
598598
* function 'vSocketClose()` to close the socket. */
599-
( void ) vSocketClose( xDHCPSocket );
599+
vSocketClose( xDHCPSocket, pdTRUE_UNSIGNED );
600600
xDHCPSocket = NULL;
601601
}
602602
}

source/FreeRTOS_IP.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
#include "NetworkBufferManagement.h"
5656
#include "FreeRTOS_DNS.h"
5757

58+
#if ( ipconfigUSE_TCP_MEM_STATS != 0 )
59+
#include "tcp_mem_stats.h"
60+
#endif
61+
5862
/* IPv4 multi-cast addresses range from 224.0.0.0.0 to 240.0.0.0. */
5963
#define ipFIRST_MULTI_CAST_IPv4 0xE0000000U /**< Lower bound of the IPv4 multicast address. */
6064
#define ipLAST_MULTI_CAST_IPv4 0xF0000000U /**< Higher bound of the IPv4 multicast address. */
@@ -357,6 +361,7 @@ static void prvProcessIPEventsAndTimers( void )
357361
* API will unblock as soon as the eSOCKET_BOUND event is
358362
* triggered. */
359363
pxSocket = ( ( FreeRTOS_Socket_t * ) xReceivedEvent.pvData );
364+
socketASSERT_IS_VALID( pxSocket );
360365
xAddress.sin_addr = 0U; /* For the moment. */
361366
xAddress.sin_port = FreeRTOS_ntohs( pxSocket->usLocalPort );
362367
pxSocket->usLocalPort = 0U;
@@ -375,7 +380,7 @@ static void prvProcessIPEventsAndTimers( void )
375380
* IP-task to actually close a socket. This is handled in
376381
* vSocketClose(). As the socket gets closed, there is no way to
377382
* report back to the API, so the API won't wait for the result */
378-
( void ) vSocketClose( ( ( FreeRTOS_Socket_t * ) xReceivedEvent.pvData ) );
383+
vSocketClose( ( ( FreeRTOS_Socket_t * ) xReceivedEvent.pvData ), pdTRUE_UNSIGNED );
379384
break;
380385

381386
case eStackTxEvent:
@@ -453,6 +458,7 @@ static void prvProcessIPEventsAndTimers( void )
453458
* received a new connection. */
454459
#if ( ipconfigUSE_TCP == 1 )
455460
pxSocket = ( ( FreeRTOS_Socket_t * ) xReceivedEvent.pvData );
461+
socketASSERT_IS_VALID( pxSocket );
456462

457463
if( xTCPCheckNewClient( pxSocket ) != pdFALSE )
458464
{

0 commit comments

Comments
 (0)