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). */
| 3027 | * If the option is active, the server will prevent writes if there are not |
| 3028 | * enough connected slaves with the specified lag (or less). */ |
| 3029 | void refreshGoodSlavesCount(void) { |
| 3030 | listIter li; |
| 3031 | listNode *ln; |
| 3032 | int good = 0; |
| 3033 | |
| 3034 | if (!server.repl_min_slaves_to_write || |
| 3035 | !server.repl_min_slaves_max_lag) return; |
| 3036 | |
| 3037 | listRewind(server.slaves,&li); |
| 3038 | while((ln = listNext(&li))) { |
| 3039 | client *slave = ln->value; |
| 3040 | time_t lag = server.unixtime - slave->repl_ack_time; |
| 3041 | |
| 3042 | if (slave->replstate == SLAVE_STATE_ONLINE && |
| 3043 | lag <= server.repl_min_slaves_max_lag) good++; |
| 3044 | } |
| 3045 | server.repl_good_slaves_count = good; |
| 3046 | } |
| 3047 | |
| 3048 | /* ----------------------- REPLICATION SCRIPT CACHE -------------------------- |
| 3049 | * The goal of this code is to keep track of scripts already sent to every |
no test coverage detected