// File: /workspace/github_c_makefile_star2_O2/redis-force[P]rpm/module/rpm.c
// Function: rpm_worker_upstream_read
static void rpm_worker_upstream_read(RedisModuleCtx *ctx, int fd, void *client_data, int mask) {
  int rd;
  rpm_context *rpm;
  redis_response_status st = REDIS_RESPONSE_OK;
  worker_pipe *pipe = client_data;
  worker_process *worker = pipe->worker;
  redis_response_reader *reader = pipe->user_data;
  char *buf = worker->buf;
  redis_response *reply = NULL;
  REDISMODULE_NOT_USED(mask);
  while ((rd = read(fd, buf, sizeof(worker->buf))) > 0) {
    redis_response_reader_feed(reader, buf, rd);
    while (st == REDIS_RESPONSE_OK && (st = redis_response_reader_next(reader, &reply)) == REDIS_RESPONSE_OK && reply != NULL) {
      st = rpm_worker_upstream_on_reply(ctx, reply);
    }
    if (st != REDIS_RESPONSE_OK) {
      /* protocol error, kill worker and restart to fix the channel */
      RedisModule_Log(ctx, "warning", "worker process respond invalid response and will be restarted to fix the state. %s",
          redis_response_reader_strerr(reader));
      rpm_worker_suicide(ctx, worker);
    }
  }
  if (rd == 0) {
    /* upstream eof, worker process must be died, restart it automatically */
    RedisModule_DeleteFileEvent(ctx, fd, REDISMODULE_READ);
    RedisModule_Log(ctx, "warning", "Upstream connection with fd %d was closed", fd);
    rpm = rpm_context_get(ctx);
    if (--worker->active_upstreams <= 0) {
      RedisModule_Log(ctx, "warning", "All upstream connections were closed, restart worker process now");
      rpm_worker_destroy(ctx, rpm, worker);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, 0x4(%rsp)
movq (%rdx), %rax
movq 0x30(%rdx), %r15
leaq 0x10(%rsp), %rcx
andq $0x0, (%rcx)
movq %rdi, %r14
movq %rax, 0x8(%rsp)
addq $0xa8, %rax
movq %rax, 0x20(%rsp)
movq 0x6ccf(%rip), %r12      # 0xdc08
pushq $0x2
popq %r13
xorl %ebx, %ebx
movl $0x100000, %edx         # imm = 0x100000
movl 0x4(%rsp), %edi
movq 0x20(%rsp), %rbp
movq %rbp, %rsi
callq 0x5180
testl %eax, %eax
jle 0x70a5
movq %r15, %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x5410
movl %ebx, %ebp
testl %ebp, %ebp
jne 0x7067
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x5130
movl %eax, %ebp
testl %eax, %eax
jne 0x705a
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x705a
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq *(%r12)
cmpl $0x2, (%rbx)
movl %r13d, %ebp
jne 0x6f6c
cmpq $0x3, 0x18(%rbx)
movl %r13d, %ebp
jne 0x6f6c
movq 0x10(%rbx), %rdx
movq (%rdx), %rcx
cmpl $0x3, (%rcx)
movl %r13d, %ebp
jne 0x6f6c
movq 0x8(%rdx), %rdx
cmpl $0x3, (%rdx)
movl %r13d, %ebp
jne 0x6f6c
movq 0x10(%rcx), %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rdx), %rbp
andq $0x0, 0x18(%rsp)
movq 0x10(%rax), %r12
movq 0x98(%r12), %rdi
movq %rbp, %rsi
pushq $0x8
popq %rdx
leaq 0x18(%rsp), %rcx
leaq 0x30(%rsp), %r8
callq 0x51d0
testl %eax, %eax
je 0x7013
movq %rbx, %rdi
callq 0x5260
jmp 0x704c
movq 0xa0(%r12), %rdi
movq 0x28(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x5400
movq 0x98(%r12), %rdi
movq %rbp, %rsi
pushq $0x8
popq %rdx
callq 0x5400
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movq 0x6e26(%rip), %rax      # 0xde70
callq *(%rax)
xorl %ebp, %ebp
movq 0x6bb3(%rip), %r12      # 0xdc08
jmp 0x6f6c
movl $0x0, %ebx
testl %ebp, %ebp
je 0x6f3f
movq 0x6dfa(%rip), %rax      # 0xde68
movq (%rax), %rbx
movq %r15, %rdi
callq 0x5310
movq %r14, %rdi
leaq 0x3d51(%rip), %rsi      # 0xadd4
leaq 0x4010(%rip), %rdx      # 0xb09a
movq %rax, %rcx
xorl %eax, %eax
callq *%rbx
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x739f
movl %ebp, %ebx
jmp 0x6f3f
jne 0x7132
movq 0x6b5e(%rip), %rax      # 0xdc10
pushq $0x1
popq %rdx
movq %r14, %rdi
movl 0x4(%rsp), %ebx
movl %ebx, %esi
callq *(%rax)
leaq 0x3d0d(%rip), %rsi      # 0xadd4
leaq 0x401f(%rip), %rdx      # 0xb0ed
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
movq 0x6d8c(%rip), %r8       # 0xde68
callq *(%r8)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq *(%r12)
movq %rax, %rbx
movq 0x8(%rsp), %rdx
movl 0x8c(%rdx), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x8c(%rdx)
cmpl $0x1, %eax
jg 0x7132
leaq 0x3cc7(%rip), %rsi      # 0xadd4
leaq 0x4003(%rip), %rdx      # 0xb117
movq %r14, %rdi
xorl %eax, %eax
movq 0x6d48(%rip), %rcx      # 0xde68
callq *(%rcx)
movq %r14, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq 0x7159
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq