patchlwIP - A Lightweight TCP/IP stack - Patches: patch #9431, Removing the restriction on number...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #9431: Removing the restriction on number of sockets

Submitter:  Joan Lledó <jllledo>
Submitted:  Tue 08 Aug 2017 05:32:30 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Planned Release:  None

Mon 01 Apr 2024 05:01:00 PM UTC, comment #5: 

Hello,

I refactored this patch to make it simpler and adapt better to the existing code.

Now it doesn't use a linked list, sockets are stored in a dynamic array. This way we can reuse all existing code to lookup and free sockets. And it only introduces a few changes in the alloc_socket() function when LWIP_SOCKET_OPEN_COUNT is enabled.

Also, since we are reusing existing code for all operations except socket allocation, complexity is the same with or without LWIP_SOCKET_OPEN_COUNT enabled:

- Alocate: O(n)
- Lookup: O(1)
- Free: O(1)

(file #55914)

Joan Lledó <jllledo>
Tue 06 Nov 2018 08:43:10 PM UTC, comment #4: 

Hmm, I also had a try at this some weeks ago. I think it would be good to separate out the allocation scheme (not calling mem_malloc hard).

Also, looking at what linux does, by now I think an overridable define for FD_SETSIZE is good enough (my linux box fixes this at 1024).

Give me some time to merge your patch with mine...

Simon Goldschmidt <goldsimon>
Group administrator
Sun 04 Nov 2018 11:11:00 AM UTC, comment #3: 

Hello,

I updated the patch to the current source, in this version, MEMP_MEM_MALLOC is not required.

About the problem with the FD_SET, I couldn't find a solution, that's why I decided to force LWIP_SOCKET_SELECT==0 when LWIP_SOCKET_OPEN_COUNT==1, and force clients to use the poll() API if they want to have unlimited number of sockets.

(file #45358)

Joan Lledó <jllledo>
Thu 10 Aug 2017 07:12:44 AM UTC, comment #2: 

Here's a new patch with those issues solved.

Regarding the MEMP_MEM_MALLOC requirement, it's there for the number of sockets to not be limited by MEMP_NUM_* macros as you suggested. Do you want me to remove it?

(file #41472)

Joan Lledó <jllledo>
Tue 08 Aug 2017 07:19:09 PM UTC, comment #1: 

The patch has some drawbacks:
- duplicated code in alloc_socket(): this is really bad as two #if/else blocks do the same. A bug fixed in one bug can remain in the 2nd block. Never do this!
- LWIP_SOCKET_OFFSET is not checked/obeyed everywhere
- alloc_socket() doesn't check for int overflow
- free_socket() doesn't follow our (old) C standard where variable declarations and code must not be mixed
- Why is MEMP_MEM_MALLOC needed?

So far to the patch, I'll reply to the general discussion on the list.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 08 Aug 2017 05:32:30 PM UTC, original submission:  

This comes from [1]

Attached is a patch that adds a new macro to allow the user to remove the limit on number of sockets.


------------
[1] http://lists.nongnu.org/archive/html/lwip-devel/2017-08/msg00029.html

Joan Lledó <jllledo>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by jllledo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-04-01 jllledo Attached File- Added 0001-Remove-restriction-on-number-of-sockets.patch, #55914
    2018-11-04 jllledo Attached File- Added 0001-Implement-sockets-open-count.patch, #45358
    2017-08-10 jllledo Attached File- Added 0001-New-option-LWIP_SOCKET_OPEN_COUNT-in-opts.h.patch, #41472
    2017-08-08 jllledo Attached File- Added 0001-New-option-LWIP_SOCKET_OPEN_COUNT-in-opts.h.patch, #41453

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code