MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / process_archive

Function process_archive

src/remote/server/ReplServer.cpp:640–1020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638 enum ProcessStatus { PROCESS_SUSPEND, PROCESS_CONTINUE, PROCESS_ERROR, PROCESS_SHUTDOWN };
639
640 ProcessStatus process_archive(MemoryPool& pool, Target* target)
641 {
642 ProcessQueue queue(pool);
643
644 ProcessStatus ret = PROCESS_SUSPEND;
645
646 const auto config = target->getConfig();
647
648 try
649 {
650 // First pass: create the processing queue
651
652 AutoPtr<PathUtils::DirIterator> iter;
653
654 for (iter = PathUtils::newDirIterator(pool, config->sourceDirectory);
655 *iter; ++(*iter))
656 {
657 if (shutdownFlag)
658 return PROCESS_SHUTDOWN;
659
660 const auto filename = **iter;
661
662#ifdef PRESERVE_LOG
663 PathName path, name;
664 PathUtils::splitLastComponent(path, name, filename);
665
666 if (name.find('~') == 0)
667 continue;
668#endif
669
670 if (filename.find('{') != PathName::npos &&
671 filename.find('}') != PathName::npos &&
672 filename.find('-') != PathName::npos)
673 {
674 continue;
675 }
676
677 const int fd = os_utils::open(filename.c_str(), O_RDONLY | O_BINARY);
678 if (fd < 0)
679 {
680 if (errno == EACCES || errno == EAGAIN)
681 {
682 target->verbose("Skipping file (%s) due to sharing violation", filename.c_str());
683 continue;
684 }
685
686 raiseError("Journal file %s open failed (error: %d)", filename.c_str(), ERRNO);
687 }
688
689 AutoFile file(fd);
690
691 struct stat stats;
692 if (fstat(file, &stats) < 0)
693 raiseError("Journal file %s fstat failed (error: %d)", filename.c_str(), ERRNO);
694
695 const size_t fileSize = stats.st_size;
696
697 if (fileSize < sizeof(SegmentHeader))

Callers 1

process_threadFunction · 0.85

Calls 15

fstatFunction · 0.85
lseekFunction · 0.85
validateHeaderFunction · 0.85
GuidToStringFunction · 0.85
findOldestFunction · 0.85
replicateFunction · 0.85
formatIntervalFunction · 0.85
verboseMethod · 0.80
checkGuidMethod · 0.80
isShutdownMethod · 0.80
initReplicaMethod · 0.80
getDbSequenceMethod · 0.80

Tested by

no test coverage detected