patchlwIP - A Lightweight TCP/IP stack - Patches: patch #5468, sockets.c: Create socksem and...

 
 

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

patch #5468: sockets.c: Create socksem and selectsem in an init-function

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Fri 20 Oct 2006 09:59:08 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  jifl Open/Closed:  Closed
Planned Release:  None

Jump to the original submission

Mon 26 Feb 2007 08:24:00 PM UTC, comment #7: 

I've checked this in now, with the mentioned changes.

Jonathan Larmour <jifl>
Group Member
Mon 26 Feb 2007 04:34:53 PM UTC, comment #6: 

My last commend was ambiguous - I meant that I think the:

if (!...)
... = sys_sem_new(1);

code should be removed.

Kieran Mansley <kieranm>
Group Member
Mon 26 Feb 2007 04:31:36 PM UTC, comment #5: 

I agree that avoiding the lazy and I think racey initialisation should be removed, and I like the proposed lwip_socket_init() name.

Jonathan - all yours, thanks.

Kieran Mansley <kieranm>
Group Member
Mon 26 Feb 2007 04:23:37 PM UTC, comment #4: 

For a lightweight stack, we really should remove redundant code where possible, so we should get rid of them IMHO. As for the name, lwip_init implies something more encompassing than what this does. lwip_socket_init seems better (and less likely to clash with something in the application).

Kieran, if you want me to take this off your plate to save you effort, I can. But I won't touch if you might be on it :).

Jonathan Larmour <jifl>
Group Member
Mon 26 Feb 2007 04:04:02 PM UTC, comment #3: 

I think that a simple way to avoid the CHANGELOG and to add the modification is to only add from the patch:

+void
+socket_init(void)
+{
+  socksem   = sys_sem_new(1);
+  selectsem = sys_sem_new(1);
+}

and to let original code like :

if (!...)
... = sys_sem_new(1);

So, ports are always compatibles, and functionnality is added (multithread-safe) to people using it.

Note: I think that lwip_init should be a better name (all others sockets.c functions are prefixed by lwip_).



Frédéric Bernon <fbernon>
Group Member
Mon 19 Feb 2007 11:16:58 AM UTC, comment #2: 

This will need some documentation (just a mention in CHANGELOG?), since this is something new for ports to do at stack init time requiring them to change.

Jonathan Larmour <jifl>
Group Member
Mon 19 Feb 2007 11:01:01 AM UTC, comment #1: 

I think this should go in.  Any objections?

Kieran Mansley <kieranm>
Group Member
Fri 20 Oct 2006 09:59:08 AM UTC, original submission:  

Created a new function, socket_init() which creates those semaphores. Must be called any time at startup of the stack, but before using sockets.

See Bug #3466 for description:

All calls to sys_sem_wait() in sockets.c are introduced by

if (!...)
... = sys_sem_new(1);

except for lwip_accept(), where sys_sem_wait() could be used on non-allocated semaphore.

(Moreover this construction is not thread-save. A task switch could occur between the decision that the semaphore needs creation and the actual call of sys_sem_new.)

Proposal: Allocate the semaphore only once, at lwip startup.

Simon Goldschmidt <goldsimon>
Group administrator

 

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

Attached Files
file #11008:  socket_init.patch added by goldsimon (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by fbernon (Posted a comment)
  • -email is unavailable- added by jifl (Posted a comment)
  • -email is unavailable- added by kieranm (Posted a comment)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-02-28 kieranm StatusNone Done
    2007-02-26 jifl Open/ClosedOpen Closed
    2007-02-26 kieranm Assigned tokieranm jifl
    2007-02-19 kieranm Assigned toNone kieranm
    2006-10-20 goldsimon Attached File- Added socket_init.patch, #11008

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code