| 3723 | const redisDbPersistentDataSnapshot *rgpdb[1]; |
| 3724 | }; |
| 3725 | void *rdbSaveToSlavesSocketsThread(void *vargs) |
| 3726 | { |
| 3727 | serverAssert(!g_pserver->rdbThreadVars.fDone); |
| 3728 | /* Child */ |
| 3729 | serverAssert(serverTL == nullptr); |
| 3730 | rdbSaveSocketThreadArgs *args = (rdbSaveSocketThreadArgs*)vargs; |
| 3731 | int retval; |
| 3732 | rio rdb; |
| 3733 | |
| 3734 | aeThreadOnline(); |
| 3735 | serverAssert(serverTL == nullptr); |
| 3736 | redisServerThreadVars vars; |
| 3737 | serverTL = &vars; |
| 3738 | vars.gcEpoch = g_pserver->garbageCollector.startEpoch(); |
| 3739 | |
| 3740 | rioInitWithFd(&rdb,args->rdb_pipe_write); |
| 3741 | |
| 3742 | retval = rdbSaveRioWithEOFMark(&rdb,args->rgpdb,NULL,&args->rsi); |
| 3743 | if (retval == C_OK && rioFlush(&rdb) == 0) |
| 3744 | retval = C_ERR; |
| 3745 | |
| 3746 | if (retval == C_OK) { |
| 3747 | sendChildCowInfo(CHILD_INFO_TYPE_RDB_COW_SIZE, "RDB"); |
| 3748 | } |
| 3749 | |
| 3750 | rioFreeFd(&rdb); |
| 3751 | close(args->rdb_pipe_write); /* wake up the reader, tell it we're done. */ |
| 3752 | /* hold exit until the parent tells us it's safe. we're not expecting |
| 3753 | * to read anything, just get the error when the pipe is closed. */ |
| 3754 | if (!g_pserver->rdbThreadVars.fRdbThreadCancel) { |
| 3755 | char dummyBuffer; |
| 3756 | auto dummy = read(args->safe_to_exit_pipe, &dummyBuffer, 1); |
| 3757 | UNUSED(dummy); |
| 3758 | } |
| 3759 | |
| 3760 | // If we were told to cancel the requesting thread is holding the lock for us |
| 3761 | for (int idb = 0; idb < cserver.dbnum; ++idb) |
| 3762 | g_pserver->db[idb]->endSnapshotAsync(args->rgpdb[idb]); |
| 3763 | |
| 3764 | g_pserver->garbageCollector.endEpoch(vars.gcEpoch); |
| 3765 | aeThreadOffline(); |
| 3766 | |
| 3767 | close(args->safe_to_exit_pipe); |
| 3768 | args->rsi.~rdbSaveInfo(); |
| 3769 | zfree(args); |
| 3770 | g_pserver->rdbThreadVars.fDone = true; |
| 3771 | return (retval == C_OK) ? (void*)0 : (void*)1; |
| 3772 | } |
| 3773 | |
| 3774 | /* Spawn an RDB child that writes the RDB to the sockets of the slaves |
| 3775 | * that are currently in SLAVE_STATE_WAIT_BGSAVE_START state. */ |
nothing calls this directly
no test coverage detected