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. */
| 3938 | * This is also called by SHUTDOWN for a best-effort attempt to send |
| 3939 | * slaves the latest writes. */ |
| 3940 | void flushSlavesOutputBuffers(void) { |
| 3941 | serverAssert(GlobalLocksAcquired()); |
| 3942 | listIter li; |
| 3943 | listNode *ln; |
| 3944 | |
| 3945 | flushReplBacklogToClients(); |
| 3946 | |
| 3947 | listRewind(g_pserver->slaves,&li); |
| 3948 | while((ln = listNext(&li))) { |
| 3949 | client *replica = (client*)listNodeValue(ln); |
| 3950 | |
| 3951 | if (!FCorrectThread(replica)) |
| 3952 | continue; // we cannot synchronously flush other thread's clients |
| 3953 | |
| 3954 | int can_receive_writes = connHasWriteHandler(replica->conn) || |
| 3955 | (replica->flags & CLIENT_PENDING_WRITE); |
| 3956 | |
| 3957 | /* We don't want to send the pending data to the replica in a few |
| 3958 | * cases: |
| 3959 | * |
| 3960 | * 1. For some reason there is neither the write handler installed |
| 3961 | * nor the client is flagged as to have pending writes: for some |
| 3962 | * reason this replica may not be set to receive data. This is |
| 3963 | * just for the sake of defensive programming. |
| 3964 | * |
| 3965 | * 2. The put_online_on_ack flag is true. To know why we don't want |
| 3966 | * to send data to the replica in this case, please grep for the |
| 3967 | * flag for this flag. |
| 3968 | * |
| 3969 | * 3. Obviously if the slave is not ONLINE. |
| 3970 | */ |
| 3971 | if (replica->replstate == SLAVE_STATE_ONLINE && |
| 3972 | can_receive_writes && |
| 3973 | !replica->repl_put_online_on_ack && |
| 3974 | clientHasPendingReplies(replica)) |
| 3975 | { |
| 3976 | writeToClient(replica,0); |
| 3977 | } |
| 3978 | } |
| 3979 | } |
| 3980 | |
| 3981 | /* Pause clients up to the specified unixtime (in ms) for a given type of |
| 3982 | * commands. |
no test coverage detected