This function puts the client in the queue of clients that should write * their output buffers to the socket. Note that it does not *yet* install * the write handler, to start clients are put in a queue of clients that need * to write, so we try to do that before returning in the event loop (see the * handleClientsWithPendingWrites() function). * If we fail and there is more data to write, co
| 211 | * If we fail and there is more data to write, compared to what the socket |
| 212 | * buffers can hold, then we'll really install the handler. */ |
| 213 | void clientInstallWriteHandler(client *c) { |
| 214 | /* Schedule the client to write the output buffers to the socket only |
| 215 | * if not already done and, for slaves, if the slave can actually receive |
| 216 | * writes at this stage. */ |
| 217 | if (!(c->flags & CLIENT_PENDING_WRITE) && |
| 218 | (c->replstate == REPL_STATE_NONE || |
| 219 | (c->replstate == SLAVE_STATE_ONLINE && !c->repl_put_online_on_ack))) |
| 220 | { |
| 221 | /* Here instead of installing the write handler, we just flag the |
| 222 | * client and put it into a list of clients that have something |
| 223 | * to write to the socket. This way before re-entering the event |
| 224 | * loop, we can try to directly write to the client sockets avoiding |
| 225 | * a system call. We'll only really install the write handler if |
| 226 | * we'll not be able to write the whole reply at once. */ |
| 227 | c->flags |= CLIENT_PENDING_WRITE; |
| 228 | listAddNodeHead(server.clients_pending_write,c); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | /* This function is called every time we are going to transmit new data |
| 233 | * to the client. The behavior is the following: |
no test coverage detected