// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x2b76e(%rip), %r14     # 0x46e80
movq 0x108(%rbx), %rsi
movl $0x200000, %edx         # imm = 0x200000
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x7130
cmpq $-0x1, %rax
je 0x1b742
testq %rax, %rax
je 0x1b871
movq (%r14), %rax
movq %rax, 0x140(%rbx)
jmp 0x1b712
callq 0x7040
movl (%rax), %edi
cmpl $0x4, %edi
je 0x1b712
cmpl $0xb, %edi
je 0x1b996
cmpl $0x68, %edi
jne 0x1b9a6
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x19c76(%rip), %rsi     # 0x353e6
leaq 0x19c7e(%rip), %rdx     # 0x353f5
leaq 0x28(%rsp), %rdi
callq 0x9760
leaq 0x48(%rsp), %rdi
movl %ebp, %esi
callq 0x12418
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1227c
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x75d0
movq (%r14), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1b7c8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x7500
leaq 0x2b2b9(%rip), %rax     # 0x46a88
movl (%rax), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
leaq 0x1927c(%rip), %rdx     # 0x34a5d
leaq 0x8(%rsp), %rdi
callq 0x96e6
movb 0x8(%rsp), %al
cmpb $0x1, %al
jne 0x1b80d
movq 0x10(%rsp), %rdi
leaq 0x1abdd(%rip), %rsi     # 0x363dc
movl $0x1d, %edx
callq 0x7570
movb 0x8(%rsp), %al
testb $0x1, %al
je 0x1b829
movq 0x10(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x7570
movb 0x8(%rsp), %al
testb $0x1, %al
je 0x1b843
movq 0x10(%rsp), %rdi
leaq 0x1abc1(%rip), %rsi     # 0x363fa
movl $0x11, %edx
callq 0x7570
leaq 0x8(%rsp), %rdi
callq 0x8f4e
xorl %ecx, %ecx
movb $0x1, %al
lock
cmpxchgb %cl, 0x10(%rbx)
sete %bpl
jne 0x1b979
movl 0x50(%rbx), %esi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
jmp 0x1b979
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x19b65(%rip), %rsi     # 0x353e6
leaq 0x19b6d(%rip), %rdx     # 0x353f5
leaq 0x28(%rsp), %rdi
callq 0x9760
leaq 0x48(%rsp), %rdi
movl %ebp, %esi
callq 0x12418
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1227c
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x75d0
movq (%r14), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1b8d9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x7500
leaq 0x2b1a8(%rip), %rax     # 0x46a88
movl (%rax), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
leaq 0x1916b(%rip), %rdx     # 0x34a5d
leaq 0x8(%rsp), %rdi
callq 0x96e6
movb 0x8(%rsp), %al
cmpb $0x1, %al
jne 0x1b91e
movq 0x10(%rsp), %rdi
leaq 0x1aacc(%rip), %rsi     # 0x363dc
movl $0x1d, %edx
callq 0x7570
movb 0x8(%rsp), %al
testb $0x1, %al
je 0x1b93a
movq 0x10(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x7570
movb 0x8(%rsp), %al
testb $0x1, %al
je 0x1b954
movq 0x10(%rsp), %rdi
leaq 0x1aac2(%rip), %rsi     # 0x3640c
movl $0x12, %edx
callq 0x7570
leaq 0x8(%rsp), %rdi
callq 0x8f4e
xorl %ecx, %ecx
movb $0x1, %al
lock
cmpxchgb %cl, 0x10(%rbx)
sete %bpl
jne 0x1b979
movl 0x50(%rbx), %esi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x1b990
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x7500
xorb $0x1, %bpl
jmp 0x1b999
movb $0x1, %bpl
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x198a9(%rip), %rsi     # 0x35256
callq 0x8d8d
jmp 0x1b9f4
jmp 0x1b9b8
jmp 0x1b9f4
movq %rax, %rbx
jmp 0x1ba0e
jmp 0x1b9bf
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x8f4e
jmp 0x1b9f7
movq %rax, %rdi
callq 0x71a0
callq 0x78e0
jmp 0x1b7c8
jmp 0x1b9f4
movq %rax, %rdi
callq 0x71a0
callq 0x78e0
jmp 0x1b8d9
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x1ba0e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x7500
movq %rbx, %rdi
callq 0x79a0