Skip to content
Snippets Groups Projects
  • deuce's avatar
    82471329
    Explicitly close sockets that fail to connect() in potentially long-running · 82471329
    deuce authored
    scripts.
    
    If the socket is not close()ed, it results in a socket descriptor leak, and on
    *nix systems, FD_SET() may corrupt memory outside of the fd_set if a socket
    descriptor higher than FD_SETSIZE is set.
    
    This manifested itself via ircd.js which called connect() to servers, but never
    called close().  After many hours, the next socket descriptor was higher than
    1024 (default FD_SETSIZE), and resulted in corruption of the private data pointer
    in js_socket.c:js_connect()... which in turn resulted in a crash.
    82471329
    History
    Explicitly close sockets that fail to connect() in potentially long-running
    deuce authored
    scripts.
    
    If the socket is not close()ed, it results in a socket descriptor leak, and on
    *nix systems, FD_SET() may corrupt memory outside of the fd_set if a socket
    descriptor higher than FD_SETSIZE is set.
    
    This manifested itself via ircd.js which called connect() to servers, but never
    called close().  After many hours, the next socket descriptor was higher than
    1024 (default FD_SETSIZE), and resulted in corruption of the private data pointer
    in js_socket.c:js_connect()... which in turn resulted in a crash.