| 3484 | } |
| 3485 | |
| 3486 | void replicationStartPendingFork(void) { |
| 3487 | /* Start a BGSAVE good for replication if we have slaves in |
| 3488 | * WAIT_BGSAVE_START state. |
| 3489 | * |
| 3490 | * In case of diskless replication, we make sure to wait the specified |
| 3491 | * number of seconds (according to configuration) so that other slaves |
| 3492 | * have the time to arrive before we start streaming. */ |
| 3493 | if (!hasActiveChildProcess()) { |
| 3494 | time_t idle, max_idle = 0; |
| 3495 | int slaves_waiting = 0; |
| 3496 | int mincapa = -1; |
| 3497 | listNode *ln; |
| 3498 | listIter li; |
| 3499 | |
| 3500 | listRewind(server.slaves,&li); |
| 3501 | while((ln = listNext(&li))) { |
| 3502 | client *slave = ln->value; |
| 3503 | if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) { |
| 3504 | idle = server.unixtime - slave->lastinteraction; |
| 3505 | if (idle > max_idle) max_idle = idle; |
| 3506 | slaves_waiting++; |
| 3507 | mincapa = (mincapa == -1) ? slave->slave_capa : |
| 3508 | (mincapa & slave->slave_capa); |
| 3509 | } |
| 3510 | } |
| 3511 | |
| 3512 | if (slaves_waiting && |
| 3513 | (!server.repl_diskless_sync || |
| 3514 | max_idle >= server.repl_diskless_sync_delay)) |
| 3515 | { |
| 3516 | /* Start the BGSAVE. The called function may start a |
| 3517 | * BGSAVE with socket target or disk target depending on the |
| 3518 | * configuration and slaves capabilities. */ |
| 3519 | startBgsaveForReplication(mincapa); |
| 3520 | } |
| 3521 | } |
| 3522 | } |
| 3523 | |
| 3524 | /* Find replica at IP:PORT from replica list */ |
| 3525 | static client *findReplica(char *host, int port) { |
no test coverage detected