MCPcopy Create free account
hub / github.com/F-Stack/f-stack / flushSlavesOutputBuffers

Function flushSlavesOutputBuffers

app/redis-6.2.6/src/networking.c:3295–3327  ·  view source on GitHub ↗

Helper function used by performEvictions() in order to flush slaves * output buffers without returning control to the event loop. * This is also called by SHUTDOWN for a best-effort attempt to send * slaves the latest writes. */

Source from the content-addressed store, hash-verified

3293 * This is also called by SHUTDOWN for a best-effort attempt to send
3294 * slaves the latest writes. */
3295void flushSlavesOutputBuffers(void) {
3296 listIter li;
3297 listNode *ln;
3298
3299 listRewind(server.slaves,&li);
3300 while((ln = listNext(&li))) {
3301 client *slave = listNodeValue(ln);
3302 int can_receive_writes = connHasWriteHandler(slave->conn) ||
3303 (slave->flags & CLIENT_PENDING_WRITE);
3304
3305 /* We don't want to send the pending data to the replica in a few
3306 * cases:
3307 *
3308 * 1. For some reason there is neither the write handler installed
3309 * nor the client is flagged as to have pending writes: for some
3310 * reason this replica may not be set to receive data. This is
3311 * just for the sake of defensive programming.
3312 *
3313 * 2. The put_online_on_ack flag is true. To know why we don't want
3314 * to send data to the replica in this case, please grep for the
3315 * flag for this flag.
3316 *
3317 * 3. Obviously if the slave is not ONLINE.
3318 */
3319 if (slave->replstate == SLAVE_STATE_ONLINE &&
3320 can_receive_writes &&
3321 !slave->repl_put_online_on_ack &&
3322 clientHasPendingReplies(slave))
3323 {
3324 writeToClient(slave,0);
3325 }
3326 }
3327}
3328
3329/* Pause clients up to the specified unixtime (in ms) for a given type of
3330 * commands.

Callers 2

performEvictionsFunction · 0.85
prepareForShutdownFunction · 0.85

Calls 5

listRewindFunction · 0.85
listNextFunction · 0.85
connHasWriteHandlerFunction · 0.85
clientHasPendingRepliesFunction · 0.85
writeToClientFunction · 0.85

Tested by

no test coverage detected