// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelPingReplyCallback
void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
    sentinelRedisInstance *ri = c->data;
    redisReply *r;

    if (ri) ri->pending_commands--;
    if (!reply || !ri) return;
    r = reply;

    if (r->type == REDIS_REPLY_STATUS ||
        r->type == REDIS_REPLY_ERROR) {

        /* Update the "instance available" field only if this is an
         * acceptable reply. */
        // 只在实例返回 acceptable 回复时更新 last_avail_time
        if (strncmp(r->str,"PONG",4) == 0 ||
            strncmp(r->str,"LOADING",7) == 0 ||
            strncmp(r->str,"MASTERDOWN",10) == 0)
        {
            // 实例运作正常
            ri->last_avail_time = mstime();
            ri->last_ping_time = 0; /* Flag the pong as received. */
        } else {

            // 实例运作不正常

            /* Send a SCRIPT KILL command if the instance appears to be
             * down because of a busy script. */
            // 如果服务器因为执行脚本而进入 BUSY 状态，
            // 那么尝试通过发送 SCRIPT KILL 来恢复服务器
            if (strncmp(r->str,"BUSY",4) == 0 &&
                (ri->flags & SRI_S_DOWN) &&
                !(ri->flags & SRI_SCRIPT_KILL_SENT))
            {
                if (redisAsyncCommand(ri->cc,
                        sentinelDiscardReplyCallback, NULL,
                        "SCRIPT KILL") == REDIS_OK)
                    ri->pending_commands++;
                ri->flags |= SRI_SCRIPT_KILL_SENT;
            }
        }
    }

    // 更新实例最后一次回复 PING 命令的时间
    ri->last_pong_time = mstime();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7dbd7
movq -0x20(%rbp), %rax
movl 0x38(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x38(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x7dbe5
cmpq $0x0, -0x20(%rbp)
jne 0x7dbea
jmp 0x7dd11
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x5, (%rax)
je 0x7dc08
movq -0x28(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x7dd01
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x64acd(%rip), %rsi     # 0xe26e4
movl $0x4, %edx
callq 0x1f340
cmpl $0x0, %eax
je 0x7dc62
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x6ba19(%rip), %rsi     # 0xe964e
movl $0x7, %edx
callq 0x1f340
cmpl $0x0, %eax
je 0x7dc62
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x6ba03(%rip), %rsi     # 0xe9656
movl $0xa, %edx
callq 0x1f340
cmpl $0x0, %eax
jne 0x7dc80
callq 0x252e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x60(%rax)
jmp 0x7dcff
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x6b9d2(%rip), %rsi     # 0xe9661
movl $0x4, %edx
callq 0x1f340
cmpl $0x0, %eax
jne 0x7dcfd
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x7dcfd
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x7dcfd
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
leaq -0x143b(%rip), %rsi     # 0x7c890
xorl %eax, %eax
movl %eax, %edx
leaq 0x6b990(%rip), %rcx     # 0xe9666
movb $0x0, %al
callq 0x86730
cmpl $0x0, %eax
jne 0x7dcef
movq -0x20(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
orl $0x2000, %ecx           # imm = 0x2000
movl %ecx, (%rax)
jmp 0x7dcff
jmp 0x7dd01
callq 0x252e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x68(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)