Skip to content

Conversation

@htibosch
Copy link
Contributor

Description

This PR does the same in the IPv6/multi branch as PR #238 did for the IPv4 branch.

Background: the function FreeRTOS_closesocket() can fail if the queue to the IP-task is full. A normal task can wait for space, but the IP-task would create a dead-lock by waiting for itself.

This PR has a safe alternative for FreeRTOS_closesocket() that can only be used by the IP-task.

Test Steps

I tested this PR by corrupting the TCP flags of an incoming packet during the SYN phase around here. That leads to an immediate closure of the socket like this:

    /* In case pxSocket is not yet owned by the application, a closure
     * of the socket will be scheduled for the next cycle. */
    vTCPStateChange( pxSocket, eCLOSE_WAIT );

Related Issue

It is recommended to make the message queue big enough so that it never gets full. Just like a stack should never overflow.
The queue length is defined as ipconfigEVENT_QUEUE_LENGTH. I often define it as:

#define ipconfigEVENT_QUEUE_LENGTH   ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )

See also uxGetMinimumIPQueueSpace(), which is defined when
ipconfigCHECK_IP_QUEUE_SPACE=1. It can be used to monitor the queue size.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@htibosch htibosch requested a review from a team as a code owner July 20, 2021 07:52
@AniruddhaKanhere AniruddhaKanhere merged commit 816686b into FreeRTOS:labs/ipv6_multi Jul 29, 2021
@htibosch htibosch deleted the IPv6/Multi_Use_vSocketCloseNextTime branch September 17, 2025 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants