From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 From: Aleksei Nikiforov To: devel@lists.altlinux.org Date: Tue, 10 Dec 2019 18:23:30 +0300 Message-Id: <20191210152343.33867-26-darktemplar@altlinux.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191210152343.33867-1-darktemplar@altlinux.org> References: <20191210152343.33867-1-darktemplar@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Aleksei Nikiforov Subject: [devel] [PATCH for apt 25/38] Check subsecond modification time for cached files X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Dec 2019 15:25:27 -0000 Archived-At: List-Archive: List-Post: --- apt/apt-pkg/pkgcache.cc | 2 +- apt/apt-pkg/pkgcache.h | 1 + apt/apt-pkg/rpm/rpmhandler.cc | 3 ++- apt/apt-pkg/rpm/rpmhandler.h | 2 ++ apt/apt-pkg/rpm/rpmindexfile.cc | 8 +++++--- apt/apt-pkg/rpm/rpmsystem.cc | 3 ++- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apt/apt-pkg/pkgcache.cc b/apt/apt-pkg/pkgcache.cc index 9965532..c9f4cfd 100644 --- a/apt/apt-pkg/pkgcache.cc +++ b/apt/apt-pkg/pkgcache.cc @@ -638,7 +638,7 @@ bool pkgCache::PkgFileIterator::IsOk() if (stat(FileName(),&Buf) != 0) return false; - if (Buf.st_size != (signed)File->Size || Buf.st_mtime != File->mtime) + if (Buf.st_size != (signed)File->Size || Buf.st_mtim.tv_sec != File->mtime || Buf.st_mtim.tv_nsec != File->mnanotime) return false; return true; diff --git a/apt/apt-pkg/pkgcache.h b/apt/apt-pkg/pkgcache.h index 56fc89d..05a63bc 100644 --- a/apt/apt-pkg/pkgcache.h +++ b/apt/apt-pkg/pkgcache.h @@ -250,6 +250,7 @@ struct pkgCache::PackageFile map_ptrloc NextFile; // PackageFile unsigned short ID; time_t mtime; // Modification time for the file + time_t mnanotime; // Subsecond modification time for the file }; struct pkgCache::VerFile diff --git a/apt/apt-pkg/rpm/rpmhandler.cc b/apt/apt-pkg/rpm/rpmhandler.cc index 46f7e0b..0bc6b4e 100644 --- a/apt/apt-pkg/rpm/rpmhandler.cc +++ b/apt/apt-pkg/rpm/rpmhandler.cc @@ -396,7 +396,8 @@ RPMDBHandler::RPMDBHandler(bool WriteLock) // restore the mtime and save our cache. struct stat St; stat(DataPath(false).c_str(), &St); - DbFileMtime = St.st_mtime; + DbFileMtime = St.st_mtim.tv_sec; + DbFileMnanotime = St.st_mtim.tv_nsec; #if RPM_VERSION >= 0x040100 Handler = rpmtsCreate(); diff --git a/apt/apt-pkg/rpm/rpmhandler.h b/apt/apt-pkg/rpm/rpmhandler.h index 196cd97..7d77603 100644 --- a/apt/apt-pkg/rpm/rpmhandler.h +++ b/apt/apt-pkg/rpm/rpmhandler.h @@ -119,6 +119,7 @@ class RPMDBHandler : public RPMHandler bool WriteLock; time_t DbFileMtime; + time_t DbFileMnanotime; public: @@ -129,6 +130,7 @@ class RPMDBHandler : public RPMHandler virtual inline bool IsDatabase() override {return true;}; virtual bool HasWriteLock() {return WriteLock;}; virtual time_t Mtime() {return DbFileMtime;} + virtual time_t Mnanotime() {return DbFileMnanotime;} virtual bool OrderedOffset() override {return false;}; RPMDBHandler(bool WriteLock=false); diff --git a/apt/apt-pkg/rpm/rpmindexfile.cc b/apt/apt-pkg/rpm/rpmindexfile.cc index ad011a7..a92e60f 100644 --- a/apt/apt-pkg/rpm/rpmindexfile.cc +++ b/apt/apt-pkg/rpm/rpmindexfile.cc @@ -383,7 +383,8 @@ bool rpmPkgListIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const return _error->Errno("stat",_("Failed to stat %s"), PackageFile.c_str()); } File->Size = St.st_size; - File->mtime = St.st_mtime; + File->mtime = St.st_mtim.tv_sec; + File->mnanotime = St.st_mtim.tv_nsec; rpmListParser Parser(Handler); if (_error->PendingError() == true) @@ -452,7 +453,7 @@ pkgCache::PkgFileIterator rpmPkgListIndex::FindInCache(pkgCache &Cache) const if (stat(File.FileName(),&St) != 0) return pkgCache::PkgFileIterator(Cache); - if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime) + if ((unsigned)St.st_size != File->Size || St.st_mtim.tv_sec != File->mtime || St.st_mtim.tv_nsec != File->mnanotime) return pkgCache::PkgFileIterator(Cache); return File; } @@ -586,6 +587,7 @@ bool rpmDatabaseIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const return _error->Errno("fstat",_("Failed to stat %s"), Handler->DataPath(false).c_str()); CFile->Size = St.st_size; CFile->mtime = Handler->Mtime(); + CFile->mnanotime = Handler->Mnanotime(); if (Gen.MergeList(Parser) == false) return _error->Error(_("Problem with MergeList %s"), @@ -624,7 +626,7 @@ pkgCache::PkgFileIterator rpmDatabaseIndex::FindInCache(pkgCache &Cache) const struct stat St; if (stat(File.FileName(),&St) != 0) return pkgCache::PkgFileIterator(Cache); - if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime) + if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime || St.st_mtim.tv_nsec != File->mnanotime) return pkgCache::PkgFileIterator(Cache); return File; } diff --git a/apt/apt-pkg/rpm/rpmsystem.cc b/apt/apt-pkg/rpm/rpmsystem.cc index fff2111..e48267c 100644 --- a/apt/apt-pkg/rpm/rpmsystem.cc +++ b/apt/apt-pkg/rpm/rpmsystem.cc @@ -486,7 +486,8 @@ static void HashOptionFile(unsigned long &Hash, const char *Name) string FileName = _config->FindFile(Name); struct stat st; stat(FileName.c_str(), &st); - Hash += st.st_mtime; + Hash += st.st_mtim.tv_sec; + Hash += st.st_mtim.tv_nsec; } unsigned long rpmSystem::OptionsHash() const { -- 2.24.0