This function counts the number of slaves with lag <= min-slaves-max-lag. * If the option is active, the server will prevent writes if there are not * enough connected slaves with the specified lag (or less). */
| 4494 | * If the option is active, the server will prevent writes if there are not |
| 4495 | * enough connected slaves with the specified lag (or less). */ |
| 4496 | void refreshGoodSlavesCount(void) { |
| 4497 | listIter li; |
| 4498 | listNode *ln; |
| 4499 | int good = 0; |
| 4500 | |
| 4501 | if (!g_pserver->repl_min_slaves_to_write || |
| 4502 | !g_pserver->repl_min_slaves_max_lag) return; |
| 4503 | |
| 4504 | listRewind(g_pserver->slaves,&li); |
| 4505 | while((ln = listNext(&li))) { |
| 4506 | client *replica = (client*)ln->value; |
| 4507 | time_t lag = g_pserver->unixtime - replica->repl_ack_time; |
| 4508 | |
| 4509 | if (replica->replstate == SLAVE_STATE_ONLINE && |
| 4510 | lag <= g_pserver->repl_min_slaves_max_lag) good++; |
| 4511 | } |
| 4512 | g_pserver->repl_good_slaves_count = good; |
| 4513 | } |
| 4514 | |
| 4515 | /* ----------------------- REPLICATION SCRIPT CACHE -------------------------- |
| 4516 | * The goal of this code is to keep track of scripts already sent to every |
no test coverage detected