// File: /workspace/github_cpp_makefile_star2_O2/cybozu[P]yrmcds/src/memcache/sockets.cpp
// Function: yrmcds::memcache::repl_socket::on_readable(int)
bool repl_socket::on_readable(int fd) {
    // recv and drop.
    while( true ) {
        ssize_t n = ::recv(fd, &m_recvbuf[0], MAX_RECVSIZE, 0);
        if( n == -1 ) {
            if( errno == EAGAIN || errno == EWOULDBLOCK )
                break;
            if( errno == EINTR )
                continue;
            if( errno == ECONNRESET ) {
                std::string addr = "unknown address";
                try {
                    addr = cybozu::get_peer_ip_address(fd).str();
                } catch (...) {
                    // ignore errors
                }
                cybozu::logger::info() << "The connection to the slave (" << addr << ") has been reset.";
                return invalidate();
            }
            cybozu::throw_unix_error(errno, "recv");
        }
        if( n == 0 ) {
            std::string addr = "unknown address";
            try {
                addr = cybozu::get_peer_ip_address(fd).str();
            } catch (...) {
                // ignore errors
            }
            cybozu::logger::info() << "The connection to the slave (" << addr << ") has been closed.";
            return invalidate();
        }
        m_last_heartbeat = g_current_time.load(relaxed);
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x60, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x238c6(%rip), %r14     # 0x3be80
movq 0x108(%rbx), %rsi
movl $0x200000, %edx         # imm = 0x200000
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x7140
cmpq $-0x1, %rax
je 0x185ea
testq %rax, %rax
je 0x18695
movq (%r14), %rax
movq %rax, 0x140(%rbx)
jmp 0x185ba
callq 0x7030
movl (%rax), %edi
cmpl $0x4, %edi
je 0x185ba
cmpl $0xb, %edi
je 0x1872b
cmpl $0x68, %edi
jne 0x18738
leaq 0xed6b(%rip), %rsi      # 0x2737a
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x84d8
leaq 0x40(%rsp), %rdi
movl %ebp, %esi
callq 0x10c2f
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x10ac8
leaq 0x20(%rsp), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0x75e0
movq %r14, %rdi
callq 0x71d0
movq %rsp, %rdi
callq 0xec96
leaq 0xfd10(%rip), %rsi      # 0x2836c
movq %rsp, %rdi
callq 0x1ac66
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x869a
leaq 0xfd12(%rip), %rsi      # 0x2838a
movq %rax, %rdi
callq 0x15262
movq %rsp, %rdi
callq 0x86e4
movq %rbx, %rdi
callq 0xf07a
jmp 0x1871d
leaq 0xecde(%rip), %rsi      # 0x2737a
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x84d8
leaq 0x40(%rsp), %rdi
movl %ebp, %esi
callq 0x10c2f
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x10ac8
leaq 0x20(%rsp), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0x75e0
movq %r14, %rdi
callq 0x71d0
movq %rsp, %rdi
callq 0xec96
leaq 0xfc83(%rip), %rsi      # 0x2836c
movq %rsp, %rdi
callq 0x1ac66
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x869a
leaq 0xfc97(%rip), %rsi      # 0x2839c
movq %rax, %rdi
callq 0x9388
movq %rsp, %rdi
callq 0x86e4
movq %rbx, %rdi
callq 0xf07a
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
callq 0x71d0
jmp 0x1872d
movb $0x1, %bl
movl %ebx, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0xeaab(%rip), %rsi      # 0x271ea
callq 0x8513
jmp 0x18775
jmp 0x1874a
jmp 0x18775
movq %rax, %rbx
jmp 0x18791
movq %rax, %rdi
callq 0x71a0
callq 0x78e0
jmp 0x1864d
jmp 0x18775
movq %rax, %rdi
callq 0x71a0
callq 0x78e0
jmp 0x186da
movq %rax, %rbx
jmp 0x18787
jmp 0x1877c
movq %rax, %rbx
movq %rsp, %rdi
callq 0x86e4
leaq 0x20(%rsp), %rdi
callq 0x71d0
movq %rbx, %rdi
callq 0x7990
nop