Send a FULLRESYNC reply in the specific case of a full resynchronization, * as a side effect setup the slave for a full sync in different ways: * * 1) Remember, into the slave client structure, the replication offset * we sent here, so that if new slaves will later attach to the same * background RDB saving process (by duplicating this client output * buffer), we can get the right o
| 493 | * BGSAVE for replication was started, or when there is one already in |
| 494 | * progress that we attached our slave to. */ |
| 495 | int replicationSetupSlaveForFullResync(client *slave, long long offset) { |
| 496 | char buf[128]; |
| 497 | int buflen; |
| 498 | |
| 499 | slave->psync_initial_offset = offset; |
| 500 | slave->replstate = SLAVE_STATE_WAIT_BGSAVE_END; |
| 501 | /* We are going to accumulate the incremental changes for this |
| 502 | * slave as well. Set slaveseldb to -1 in order to force to re-emit |
| 503 | * a SELECT statement in the replication stream. */ |
| 504 | server.slaveseldb = -1; |
| 505 | |
| 506 | /* Don't send this reply to slaves that approached us with |
| 507 | * the old SYNC command. */ |
| 508 | if (!(slave->flags & CLIENT_PRE_PSYNC)) { |
| 509 | buflen = snprintf(buf,sizeof(buf),"+FULLRESYNC %s %lld\r\n", |
| 510 | server.replid,offset); |
| 511 | if (connWrite(slave->conn,buf,buflen) != buflen) { |
| 512 | freeClientAsync(slave); |
| 513 | return C_ERR; |
| 514 | } |
| 515 | } |
| 516 | return C_OK; |
| 517 | } |
| 518 | |
| 519 | /* This function handles the PSYNC command from the point of view of a |
| 520 | * master receiving a request for partial resynchronization. |
no test coverage detected