• Andrey Vagin's avatar
    sk-inet: restore option REUSEADDR (v2) · a74605a7
    Andrey Vagin authored
    All sockets are created with SO_REUSEADDR, it's needed for restoring.
    E.g.: A listen socket is created after a connected socket. Both of them
    are binded to one port.
    
    So SO_REUSEADDR should be restored, when all sockets on a port were created.
    
    This code creates a structure for each port of one type of sockets
    and accounts a number of sockets, which are not restored yet.
    
    Sockets have a hook post_open(), in which it waits when all sockets for
    a defined port would be created and then it will restore SO_REUSEADDR.
    
    struct port contains a type (udp, tcp, etc) and a port number.
    It doesn't contain family or addr, because it's extra loads of logic,
    which doesn't bring a significant profits.
    
    v2: fix according with comments from Pavel
    Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    a74605a7
sockets.c 7.8 KB