// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/networking.c
// Function: acceptCommonHandler
static void acceptCommonHandler(int fd, int flags, char *ip) {
    client *c;
    if ((c = createClient(fd)) == NULL) {
        serverLog(LL_WARNING,
            "Error registering fd event for the new client: %s (fd=%d)",
            strerror(errno),fd);
        close(fd); /* May be already closed, just ignore errors */
        return;
    }
    /* If maxclient directive is set and this is one client more... close the
     * connection. Note that we create the client instead to check before
     * for this condition, since now the socket is already set in non-blocking
     * mode and we can send an error for free using the Kernel I/O */
    if (listLength(server.clients) > server.maxclients) {
        char *err = "-ERR max number of clients reached\r\n";

        /* That's a best effort error message, don't check write errors */
        if (write(c->fd,err,strlen(err)) == -1) {
            /* Nothing to do, Just to avoid the warning... */
        }
        server.stat_rejected_conn++;
        freeClient(c);
        return;
    }

    /* If the server is running in protected mode (the default) and there
     * is no password set, nor a specific interface is bound, we don't accept
     * requests from non loopback interfaces. Instead we try to explain the
     * user what to do to fix it if needed. */
    if (server.protected_mode &&
        server.bindaddr_count == 0 &&
        server.requirepass == NULL &&
        !(flags & CLIENT_UNIX_SOCKET) &&
        ip != NULL)
    {
        if (strcmp(ip,"127.0.0.1") && strcmp(ip,"::1")) {
            char *err =
                "-DENIED Redis is running in protected mode because protected "
                "mode is enabled, no bind address was specified, no "
                "authentication password is requested to clients. In this mode "
                "connections are only accepted from the loopback interface. "
                "If you want to connect from external computers to Redis you "
                "may adopt one of the following solutions: "
                "1) Just disable protected mode sending the command "
                "'CONFIG SET protected-mode no' from the loopback interface "
                "by connecting to Redis from the same host the server is "
                "running, however MAKE SURE Redis is not publicly accessible "
                "from internet if you do so. Use CONFIG REWRITE to make this "
                "change permanent. "
                "2) Alternatively you can just disable the protected mode by "
                "editing the Redis configuration file, and setting the protected "
                "mode option to 'no', and then restarting the server. "
                "3) If you started the server manually just for testing, restart "
                "it with the '--protected-mode no' option. "
                "4) Setup a bind address or an authentication password. "
                "NOTE: You only need to do one of the above things in order for "
                "the server to start accepting connections from the outside.\r\n";
            if (write(c->fd,err,strlen(err)) == -1) {
                /* Nothing to do, Just to avoid the warning... */
            }
            server.stat_rejected_conn++;
            freeClient(c);
            return;
        }
    }

    server.stat_numconnections++;
    c->flags |= flags;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %ebp
movl %edi, %r15d
callq 0x36144
testq %rax, %rax
je 0x3739a
movq %rax, %rbx
leaq 0xc254d(%rip), %r15     # 0xf98a8
movq 0x1c8(%r15), %rax
movl 0x904(%r15), %ecx
cmpq %rcx, 0x28(%rax)
jbe 0x373cf
movl 0x8(%rbx), %edi
leaq 0x7ab97(%rip), %rsi     # 0xb1f10
pushq $0x24
popq %rdx
callq 0x26bb0
incq 0x3d8(%r15)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x37527
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x7ab29(%rip), %rsi     # 0xb1ed6
pushq $0x3
popq %rdi
movq %rax, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2b699
movl %r15d, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x26180
cmpl $0x0, 0x318(%r15)
je 0x37436
cmpl $0x0, 0x128(%r15)
jne 0x37436
cmpq $0x0, 0x58(%r15)
jne 0x37436
movl %ebp, %eax
shrl $0xb, %eax
andl $0x1, %eax
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x37436
leaq 0x7ab32(%rip), %rsi     # 0xb1f35
movq %r14, %rdi
callq 0x268f0
testl %eax, %eax
je 0x37436
leaq 0x7ab29(%rip), %rsi     # 0xb1f3f
movq %r14, %rdi
callq 0x268f0
testl %eax, %eax
je 0x37436
movl 0x8(%rbx), %edi
leaq 0x7ab17(%rip), %rsi     # 0xb1f43
movl $0x44d, %edx            # imm = 0x44D
jmp 0x3737c
incq 0x398(%r15)
orl %ebp, 0x98(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq