mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Update FreeRTOS_FD_SET() to check there is enough space in the queue before adding the socket to the socket set.
This commit is contained in:
parent
10fa546e60
commit
0c849fa597
|
@ -105,17 +105,18 @@ xExampleDebugStatEntry_t xIPTraceValues[] =
|
||||||
{
|
{
|
||||||
/* Comment out array entries to remove individual trace items. */
|
/* Comment out array entries to remove individual trace items. */
|
||||||
|
|
||||||
|
{ iptraceID_NETWORK_INTERFACE_RECEIVE, ( const uint8_t * const ) "Packets received by the network interface", prvIncrementEventCount, 0 },
|
||||||
|
{ iptraceID_NETWORK_INTERFACE_TRANSMIT, ( const uint8_t * const ) "Count of transmitted packets", prvIncrementEventCount, 0 },
|
||||||
|
{ iptraceID_PACKET_DROPPED_TO_GENERATE_ARP, ( const uint8_t * const ) "Count of packets dropped to generate ARP", prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_NETWORK_BUFFER_OBTAINED, ( const uint8_t * const ) "Lowest ever available network buffers", prvStoreLowest, 0xffffUL },
|
{ iptraceID_NETWORK_BUFFER_OBTAINED, ( const uint8_t * const ) "Lowest ever available network buffers", prvStoreLowest, 0xffffUL },
|
||||||
{ iptraceID_NETWORK_EVENT_RECEIVED, ( const uint8_t * const ) "Lowest ever free space in network event queue", prvStoreLowest, 0xffffUL },
|
{ iptraceID_NETWORK_EVENT_RECEIVED, ( const uint8_t * const ) "Lowest ever free space in network event queue", prvStoreLowest, 0xffffUL },
|
||||||
{ iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER, ( const uint8_t * const ) "Count of failed attempts to obtain a network buffer",prvIncrementEventCount, 0 },
|
{ iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER, ( const uint8_t * const ) "Count of failed attempts to obtain a network buffer",prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_ARP_TABLE_ENTRY_EXPIRED, ( const uint8_t * const ) "Count of expired ARP entries", prvIncrementEventCount, 0 },
|
{ iptraceID_ARP_TABLE_ENTRY_EXPIRED, ( const uint8_t * const ) "Count of expired ARP entries", prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_PACKET_DROPPED_TO_GENERATE_ARP, ( const uint8_t * const ) "Count of packets dropped to generate ARP", prvIncrementEventCount, 0 },
|
|
||||||
{ iptraceID_FAILED_TO_CREATE_SOCKET, ( const uint8_t * const ) "Count of failures to create a socket", prvIncrementEventCount, 0 },
|
{ iptraceID_FAILED_TO_CREATE_SOCKET, ( const uint8_t * const ) "Count of failures to create a socket", prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_RECVFROM_DISCARDING_BYTES, ( const uint8_t * const ) "Count of times recvfrom() has discarding bytes", prvIncrementEventCount, 0 },
|
{ iptraceID_RECVFROM_DISCARDING_BYTES, ( const uint8_t * const ) "Count of times recvfrom() has discarding bytes", prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_ETHERNET_RX_EVENT_LOST, ( const uint8_t * const ) "Count of lost Ethenret Rx events (event queue full?)",prvIncrementEventCount, 0 },
|
{ iptraceID_ETHERNET_RX_EVENT_LOST, ( const uint8_t * const ) "Count of lost Ethenret Rx events (event queue full?)",prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_STACK_TX_EVENT_LOST, ( const uint8_t * const ) "Count of lost IP stack events (event queue full?)", prvIncrementEventCount, 0 },
|
{ iptraceID_STACK_TX_EVENT_LOST, ( const uint8_t * const ) "Count of lost IP stack events (event queue full?)", prvIncrementEventCount, 0 },
|
||||||
{ ipconfigID_BIND_FAILED, ( const uint8_t * const ) "Count of failed calls to bind()", prvIncrementEventCount, 0 },
|
{ ipconfigID_BIND_FAILED, ( const uint8_t * const ) "Count of failed calls to bind()", prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_NETWORK_INTERFACE_TRANSMIT, ( const uint8_t * const ) "Count of transmitted packets", prvIncrementEventCount, 0 },
|
|
||||||
{ iptraceID_RECVFROM_TIMEOUT, ( const uint8_t * const ) "Count of receive timeouts", prvIncrementEventCount, 0 },
|
{ iptraceID_RECVFROM_TIMEOUT, ( const uint8_t * const ) "Count of receive timeouts", prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_SENDTO_DATA_TOO_LONG, ( const uint8_t * const ) "Count of failed sends due to oversized payload", prvIncrementEventCount, 0 },
|
{ iptraceID_SENDTO_DATA_TOO_LONG, ( const uint8_t * const ) "Count of failed sends due to oversized payload", prvIncrementEventCount, 0 },
|
||||||
{ iptraceID_SENDTO_SOCKET_NOT_BOUND, ( const uint8_t * const ) "Count of failed sends due to unbound socket", prvIncrementEventCount, 0 },
|
{ iptraceID_SENDTO_SOCKET_NOT_BOUND, ( const uint8_t * const ) "Count of failed sends due to unbound socket", prvIncrementEventCount, 0 },
|
||||||
|
|
|
@ -85,18 +85,21 @@ typedef struct ExampleDebugStatEntry
|
||||||
|
|
||||||
/* Unique identifiers used to locate the entry for each trace macro in the
|
/* Unique identifiers used to locate the entry for each trace macro in the
|
||||||
xIPTraceValues[] table defined in DemoIPTrace.c. */
|
xIPTraceValues[] table defined in DemoIPTrace.c. */
|
||||||
#define iptraceID_NETWORK_BUFFER_OBTAINED 1
|
#define iptraceID_NETWORK_INTERFACE_RECEIVE 0
|
||||||
#define iptraceID_NETWORK_BUFFER_OBTAINED_FROM_ISR 2
|
#define iptraceID_NETWORK_INTERFACE_TRANSMIT 1
|
||||||
#define iptraceID_NETWORK_EVENT_RECEIVED 3
|
#define iptraceID_PACKET_DROPPED_TO_GENERATE_ARP 2
|
||||||
#define iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER 4
|
/* Do not change IDs above this line as the ID is shared with a FreeRTOS+Nabto
|
||||||
#define iptraceID_ARP_TABLE_ENTRY_EXPIRED 5
|
demo. */
|
||||||
#define iptraceID_PACKET_DROPPED_TO_GENERATE_ARP 6
|
#define iptraceID_NETWORK_BUFFER_OBTAINED 3
|
||||||
#define iptraceID_FAILED_TO_CREATE_SOCKET 7
|
#define iptraceID_NETWORK_BUFFER_OBTAINED_FROM_ISR 4
|
||||||
#define iptraceID_RECVFROM_DISCARDING_BYTES 8
|
#define iptraceID_NETWORK_EVENT_RECEIVED 5
|
||||||
#define iptraceID_ETHERNET_RX_EVENT_LOST 9
|
#define iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER 6
|
||||||
#define iptraceID_STACK_TX_EVENT_LOST 10
|
#define iptraceID_ARP_TABLE_ENTRY_EXPIRED 7
|
||||||
#define ipconfigID_BIND_FAILED 11
|
#define iptraceID_FAILED_TO_CREATE_SOCKET 8
|
||||||
#define iptraceID_NETWORK_INTERFACE_TRANSMIT 12
|
#define iptraceID_RECVFROM_DISCARDING_BYTES 9
|
||||||
|
#define iptraceID_ETHERNET_RX_EVENT_LOST 10
|
||||||
|
#define iptraceID_STACK_TX_EVENT_LOST 11
|
||||||
|
#define ipconfigID_BIND_FAILED 12
|
||||||
#define iptraceID_RECVFROM_TIMEOUT 13
|
#define iptraceID_RECVFROM_TIMEOUT 13
|
||||||
#define iptraceID_SENDTO_DATA_TOO_LONG 14
|
#define iptraceID_SENDTO_DATA_TOO_LONG 14
|
||||||
#define iptraceID_SENDTO_SOCKET_NOT_BOUND 15
|
#define iptraceID_SENDTO_SOCKET_NOT_BOUND 15
|
||||||
|
@ -136,6 +139,7 @@ configINCLUDE_DEMO_DEBUG_STATS setting in FreeRTOSIPConfig.h. */
|
||||||
#define iptraceNO_BUFFER_FOR_SENDTO() vExampleDebugStatUpdate( iptraceID_NO_BUFFER_FOR_SENDTO, 0 )
|
#define iptraceNO_BUFFER_FOR_SENDTO() vExampleDebugStatUpdate( iptraceID_NO_BUFFER_FOR_SENDTO, 0 )
|
||||||
#define iptraceWAITING_FOR_TX_DMA_DESCRIPTOR() vExampleDebugStatUpdate( iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR, 0 )
|
#define iptraceWAITING_FOR_TX_DMA_DESCRIPTOR() vExampleDebugStatUpdate( iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR, 0 )
|
||||||
#define iptraceFAILED_TO_NOTIFY_SELECT_GROUP( xSocket ) vExampleDebugStatUpdate( iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP, 0 )
|
#define iptraceFAILED_TO_NOTIFY_SELECT_GROUP( xSocket ) vExampleDebugStatUpdate( iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP, 0 )
|
||||||
|
#define iptraceNETWORK_INTERFACE_RECEIVE() vExampleDebugStatUpdate( iptraceID_NETWORK_INTERFACE_RECEIVE, 0 )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The function that updates a line in the xIPTraceValues table.
|
* The function that updates a line in the xIPTraceValues table.
|
||||||
|
|
6
FreeRTOS-Plus/Source/FreeRTOS-Plus-Nabto/readme.txt
Normal file
6
FreeRTOS-Plus/Source/FreeRTOS-Plus-Nabto/readme.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FreeRTOS+Nabto projects are currently provided in a separate
|
||||||
|
download. Following are links to the download page and the
|
||||||
|
documentation for the demo that is included in the download.
|
||||||
|
|
||||||
|
http://www.freertos.org/FreeRTOS-Plus/Nabto/download_freertos_plus_nabto.shtml
|
||||||
|
http://www.freertos.org/FreeRTOS-Plus/Nabto/getting_started_with_FreeRTOS_Plus_Nabto.shtml
|
|
@ -186,21 +186,39 @@ xFreeRTOS_Socket_t *pxSocket;
|
||||||
portBASE_TYPE FreeRTOS_FD_SET( xSocket_t xSocket, xSocketSet_t xSocketSet )
|
portBASE_TYPE FreeRTOS_FD_SET( xSocket_t xSocket, xSocketSet_t xSocketSet )
|
||||||
{
|
{
|
||||||
xFreeRTOS_Socket_t *pxSocket = ( xFreeRTOS_Socket_t * ) xSocket;
|
xFreeRTOS_Socket_t *pxSocket = ( xFreeRTOS_Socket_t * ) xSocket;
|
||||||
portBASE_TYPE xReturn;
|
portBASE_TYPE xReturn = pdFALSE;
|
||||||
|
unsigned portBASE_TYPE uxMessagesWaiting;
|
||||||
|
|
||||||
|
configASSERT( xSocket );
|
||||||
|
|
||||||
/* Is the socket already a member of a select group? */
|
/* Is the socket already a member of a select group? */
|
||||||
if( pxSocket->xSelectQueue == NULL )
|
if( pxSocket->xSelectQueue == NULL )
|
||||||
{
|
{
|
||||||
/* Store a pointer to the select group in the socket for future
|
taskENTER_CRITICAL();
|
||||||
reference. */
|
{
|
||||||
pxSocket->xSelectQueue = ( xQueueHandle ) xSocketSet;
|
/* Are there packets queued on the socket already? */
|
||||||
xReturn = pdPASS;
|
uxMessagesWaiting = uxQueueMessagesWaiting( pxSocket->xWaitingPacketSemaphore );
|
||||||
}
|
|
||||||
else
|
/* Are there enough notification spaces in the select queue for the
|
||||||
{
|
number of packets already queued on the socket? */
|
||||||
/* The socket is already a member of a select group so cannot be added
|
if( uxQueueSpacesAvailable( ( xQueueHandle ) xSocketSet ) >= uxMessagesWaiting )
|
||||||
to another. */
|
{
|
||||||
xReturn = pdFAIL;
|
/* Store a pointer to the select group in the socket for
|
||||||
|
future reference. */
|
||||||
|
pxSocket->xSelectQueue = ( xQueueHandle ) xSocketSet;
|
||||||
|
|
||||||
|
while( uxMessagesWaiting > 0 )
|
||||||
|
{
|
||||||
|
/* Add notifications of the number of packets that are
|
||||||
|
already queued on the socket to the select queue. */
|
||||||
|
xQueueSendFromISR( pxSocket->xSelectQueue, &pxSocket, NULL );
|
||||||
|
uxMessagesWaiting--;
|
||||||
|
}
|
||||||
|
|
||||||
|
xReturn = pdPASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
}
|
}
|
||||||
|
|
||||||
return xReturn;
|
return xReturn;
|
||||||
|
|
|
@ -147,4 +147,8 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
||||||
#define ipconfigNABTO_TASK_PRIORITY ( ipconfigUDP_TASK_PRIORITY + 1 )
|
#define ipconfigNABTO_TASK_PRIORITY ( ipconfigUDP_TASK_PRIORITY + 1 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ipconfigSUPPORT_SELECT_FUNCTION
|
||||||
|
#define ipconfigSUPPORT_SELECT_FUNCTION 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* FREERTOS_DEFAULT_IP_CONFIG_H */
|
#endif /* FREERTOS_DEFAULT_IP_CONFIG_H */
|
||||||
|
|
Loading…
Reference in a new issue