buglwIP - A Lightweight TCP/IP stack - Bugs: bug #20288, event_callback is called from...

 
 

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

bug #20288: event_callback is called from multiple threads without locking

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Thu 28 Jun 2007 10:52:47 AM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Wont Fix
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  None

Wed 25 Jul 2007 06:06:12 PM UTC, comment #3: 


> Also, things can be sped up if we use SYS_ARCH_PROTECT here
> instead of a semaphore


I don't plan to change this for the 'old' socket layer, so I'm closing this.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 13 Jul 2007 05:02:10 PM UTC, comment #2: 

Hmm, as long as we only look at the socket layer (which is the only code really using the callbacks inside the stack), it seems I didn't read the code properly: it is protected right now, only this is done with a semaphore in sockets.c:event_callback().

The only thing not protected (an thus needing a change) is for data coming in right after an accept (on the newconn). That would need protection.

Also, things can be sped up if we use SYS_ARCH_PROTECT here instead of a semaphore, but this is true for the whole socket layer...

Simon Goldschmidt <goldsimon>
Group administrator
Sat 30 Jun 2007 03:19:41 PM UTC, comment #1: 

There is also a call in netconn_accept. For netconn_recv, for the TCP part, I think it's easy to move the callback inside the do_recv. For the RAW/UDP part, there is no such call (do_recv), so, add one will add a thread-context switch, and it's not a good idea.

Tips for LWIP_SOCKETS_SELECT & LWIP_NONBLOCKING_SOCKETS (from patch #5919): to avoid calls, it will be good to use a define like :

#if LWIP_SOCKETS_SELECT || LWIP_NONBLOCKING_SOCKETS
#define API_CALLBACK(conn,evt,len) {if (conn->callback) conn->callback( conn, evt, len);}
#else  /* LWIP_SOCKETS_SELECT || LWIP_NONBLOCKING_SOCKETS */
#define API_CALLBACK(conn,evt,len)
#endif /* LWIP_SOCKETS_SELECT || LWIP_NONBLOCKING_SOCKETS */

And replace all "conn->callback" by API_CALLBACK...

Frédéric Bernon <fbernon>
Group Member
Thu 28 Jun 2007 10:52:47 AM UTC, original submission:  

conn->callback is called from api_msg.c in the core-receive-callbacks (recv_raw/recv_udp/recv_tcp) but also from netconn_recv, when data was received by the application. This is definitively not thread-safe.

I think this only leads to problems when using non-blocking sockets or select, so this bug is a bit related to patch #5919 (Create compile switch to remove select code) [which is closed for now since it's not that important].

Simon Goldschmidt <goldsimon>
Group administrator

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kieranm (Updated the item)
  • -email is unavailable- added by fbernon (Posted a comment)
  • -email is unavailable- added by goldsimon (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-07-25 goldsimon StatusNone Wont Fix
        Open/ClosedOpen Closed
    2007-07-13 kieranm Planned Release 1.3.0

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code