• Oran Agra's avatar
    Use accept4 on linux instead of fcntl to make a client socket non-blocking (#9177) · 5a3de819
    Oran Agra authored
    
    
    This reduces system calls on linux when a new connection is made / accepted.
    
    Changes:
    * Add the SOCK_CLOEXEC option to the accept4() call
      This  ensure that a fork/exec call does not leak a file descriptor.
    * Move anetCloexec and connNonBlock info anetGenericAccept
    * Moving connNonBlock from accept handlers to anetGenericAccept
    
    Moving connNonBlock from createClient, is safe because createClient is
    used in the following ways:
    1. without a connection (fake client)
    2. on an accepted connection (see above)
    3. creating the master client by using connConnect (see below)
    
    The third case, can either use anetTcpNonBlockConnect, or connTLSConnect
    which is by default non-blocking.
    Co-authored-by: default avatarRajiv Kurian <geetasen@gmail.com>
    Co-authored-by: default avatarOran Agra <oran@redislabs.com>
    Co-authored-by: default avatarYoav Steinberg <yoav@redislabs.com>
    5a3de819
anet.c 19.6 KB