Skip to content
  • Gilles Chanteperdrix's avatar
    rtnet/socket: rework reference counting · 45474093
    Gilles Chanteperdrix authored and Philippe Gerum's avatar Philippe Gerum committed
    With socket pools allocations locking sockets, when a received packet
    switches from the device pool to the socket pool and is queued in a
    socket incoming queue, the socket is locked preventing its destruction
    until all packets have been received. This is probably the reason for
    this bug report:
    http://xenomai.org/pipermail/xenomai/2015-June/034345.html
    
    Furthermore, when looking at the code in af_packet.c when a packet has
    been acquired by the socket pool, but is not yet queued, the socket is
    locked, so, the socket can not disappear and the packet leak, so the
    locking is redundant. The case of ip_input.c is a bit different as there
    is a small window where a packet is in flight and a socket can be
    closed, but this can been fixed.
    
    What can happen however, is that a module can be removed in the middle
    of the packet reception, causing all sorts of trouble.
    
    So, this commit:
    - suppresses the locking of sockets by the socket pool allocation;
    - gets sockets creation to lock the module in which they are created;
    - fixes packet delivery in ip_input.c to lock the destination socket as
    long as the packet has not been delivered.
    45474093