• Johny Mattsson's avatar
    Fix net module data loss & RTOS task unsafety (#2829) · f44e6e96
    Johny Mattsson authored
    To avoid races between the lwIP callbacks (lwIP RTOS task) and the Lua
    handlers (LVM RTOS task), the data flow and ownership has been simplified
    and cleaned up.
    
    lwIP callbacks now have no visibility of the userdata struct. They are
    limited to creating small event objects and task_post()ing them over
    to the LVM "thread", passing ownership in doing so. The shared identifier
    then becomes the struct netconn*.
    
    On the LVM side, we keep a linked list of active userdata objects. This
    allows us to retrieve the correct userdata when we get an event with
    a netconn pointer. Because this list is only ever used within the LVM
    task, no locking is necessary.
    
    The old approach of stashing a userdata pointer into the 'socket' field
    on the netconn has been removed entirely, as this was both not
    thread/RTOS-task safe, and also interfered with the IDFs internal use
    of the socket field (even when using only the netconn layer). As an
    added benefit, this r...
    f44e6e96
task.c 3.88 KB