Describe the bug

when we have many fds need to reply。 clientHasPendingReplies always return 1. so clients do not add to client_pending_write list ,instead of AE_WRITE event。 in this case handleClientsWithPendingWritesUsingThreads does not work。 To reproduce int prepareClientToWrite(client *c) { if (!clientHasPendingReplies(c) && io_threads_op == IO_THREADS_OP_IDLE) clientInstallWriteHandler(c);

/* Authorize the caller to queue in the output buffer of this client. */
return C_OK;

}

Expected behavior

Additional information

here is my patch::

int prepareClientToWrite(client *c) {

if (!clientHasPendingReplies(c)) {
    serverLog(LL_DEBUG," client %s flags %lld no data, need to add clients_pending_write %d  ",
        c->name==NULL ? "NA" : (char*)c->name->ptr,c->flags,
        (int)listLength(server.clients_pending_write));
    if (io_threads_op  == IO_THREADS_OP_IDLE) {
        clientInstallWriteHandler(c);
    }

} else {
    serverLog(LL_DEBUG," client %s flags %lld have data,  clients_pending_write %d  ",
        c->name==NULL ? "NA" : (char*)c->name->ptr,c->flags,
        (int)listLength(server.clients_pending_write));

     int events = aeGetFileEvents(server.el,c->conn->fd);
     if ((events & AE_WRITABLE) && aeWait(c->conn->fd,AE_WRITABLE,0)) {
         serverLog(LL_DEBUG," %s hasAE_WRITABLE  socket writeable delAE_WRITABLE add clients_pending_write", 
             c->name==NULL ? "NA" : (char*)c->name->ptr);        
         connSetWriteHandler(c->conn, NULL);
         clientInstallWriteHandler(c);
     }
}
/* Authorize the caller to queue in the output buffer of this client. */
return C_OK;

}