From 4632b860d1576d049b1c86741b05443beb26e379 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 1 Mar 2023 10:55:48 +0000 Subject: Use typesafe time for file modification time. --- .../vespa/searchcore/proton/server/fileconfigmanager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index f22f57979b4..c16a89f4e2b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -94,9 +94,9 @@ class ConfigFile { using SP = std::shared_ptr; - vespalib::string _name; - time_t _modTime; - std::vector _content; + vespalib::string _name; + vespalib::system_time _modTime; + std::vector _content; public: ConfigFile(); @@ -111,7 +111,7 @@ public: ConfigFile::ConfigFile() : _name(), - _modTime(0), + _modTime(), _content() { } @@ -120,7 +120,7 @@ ConfigFile::~ConfigFile() = default; ConfigFile::ConfigFile(const vespalib::string &name, const vespalib::string &fullName) : _name(name), - _modTime(0), + _modTime(), _content() { FastOS_File file; @@ -130,7 +130,7 @@ ConfigFile::ConfigFile(const vespalib::string &name, const vespalib::string &ful int64_t fileSize = file.getSize(); _content.resize(fileSize); file.ReadBuf(_content.data(), fileSize); - _modTime = file.GetModificationTime(); + _modTime = file.getModificationTime(); } nbostream & @@ -138,7 +138,7 @@ ConfigFile::serialize(nbostream &stream) const { assert(strchr(_name.c_str(), '/') == nullptr); stream << _name; - stream << static_cast(_modTime);; + stream << vespalib::count_s(_modTime.time_since_epoch()); uint32_t sz = _content.size(); stream << sz; stream.write(_content.data(), sz); @@ -152,7 +152,7 @@ ConfigFile::deserialize(nbostream &stream) assert(strchr(_name.c_str(), '/') == nullptr); int64_t modTime; stream >> modTime; - _modTime = modTime; + _modTime = vespalib::system_time(vespalib::from_s(modTime)); uint32_t sz; stream >> sz; _content.resize(sz); -- cgit v1.2.3 From c1bf5ab8409d2c2b29b6d6a34d6ecac2423ac005 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 1 Mar 2023 11:30:50 +0000 Subject: GC unused functionality. --- .../searchcore/proton/server/fileconfigmanager.cpp | 11 ++----- vespalib/src/vespa/fastlib/io/bufferedfile.cpp | 6 ---- vespalib/src/vespa/fastlib/io/bufferedfile.h | 7 +--- vespalib/src/vespa/fastos/file.h | 37 ++-------------------- vespalib/src/vespa/fastos/unix_file.cpp | 22 ------------- vespalib/src/vespa/fastos/unix_file.h | 5 --- 6 files changed, 6 insertions(+), 82 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index c16a89f4e2b..7ee6a02d03e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -95,7 +95,6 @@ class ConfigFile using SP = std::shared_ptr; vespalib::string _name; - vespalib::system_time _modTime; std::vector _content; public: @@ -111,7 +110,6 @@ public: ConfigFile::ConfigFile() : _name(), - _modTime(), _content() { } @@ -120,7 +118,6 @@ ConfigFile::~ConfigFile() = default; ConfigFile::ConfigFile(const vespalib::string &name, const vespalib::string &fullName) : _name(name), - _modTime(), _content() { FastOS_File file; @@ -130,7 +127,6 @@ ConfigFile::ConfigFile(const vespalib::string &name, const vespalib::string &ful int64_t fileSize = file.getSize(); _content.resize(fileSize); file.ReadBuf(_content.data(), fileSize); - _modTime = file.getModificationTime(); } nbostream & @@ -138,7 +134,7 @@ ConfigFile::serialize(nbostream &stream) const { assert(strchr(_name.c_str(), '/') == nullptr); stream << _name; - stream << vespalib::count_s(_modTime.time_since_epoch()); + stream << int64_t(0ul); // Used to be modtime => unused uint32_t sz = _content.size(); stream << sz; stream.write(_content.data(), sz); @@ -150,9 +146,8 @@ ConfigFile::deserialize(nbostream &stream) { stream >> _name; assert(strchr(_name.c_str(), '/') == nullptr); - int64_t modTime; - stream >> modTime; - _modTime = vespalib::system_time(vespalib::from_s(modTime)); + int64_t unused_modTime; + stream >> unused_modTime; uint32_t sz; stream >> sz; _content.resize(sz); diff --git a/vespalib/src/vespa/fastlib/io/bufferedfile.cpp b/vespalib/src/vespa/fastlib/io/bufferedfile.cpp index 3f02a30e1c4..aecf08edf6b 100644 --- a/vespalib/src/vespa/fastlib/io/bufferedfile.cpp +++ b/vespalib/src/vespa/fastlib/io/bufferedfile.cpp @@ -107,12 +107,6 @@ Fast_BufferedFile::Sync() return _file->Sync(); } -vespalib::system_time -Fast_BufferedFile::getModificationTime() -{ - return _file->getModificationTime(); -} - void Fast_BufferedFile::EnableDirectIO() { diff --git a/vespalib/src/vespa/fastlib/io/bufferedfile.h b/vespalib/src/vespa/fastlib/io/bufferedfile.h index 748fa6fd06c..2a5e0ec7535 100644 --- a/vespalib/src/vespa/fastlib/io/bufferedfile.h +++ b/vespalib/src/vespa/fastlib/io/bufferedfile.h @@ -172,12 +172,7 @@ public: * Force completion of pending disk writes (flush cache). */ [[nodiscard]] bool Sync() override; - /** - * Get the time the file was last modified. - * - * @return time_t The last modification time. - */ - vespalib::system_time getModificationTime() override; + /** * Turn on direct IO. */ diff --git a/vespalib/src/vespa/fastos/file.h b/vespalib/src/vespa/fastos/file.h index d2c290360e8..371a43e27b6 100644 --- a/vespalib/src/vespa/fastos/file.h +++ b/vespalib/src/vespa/fastos/file.h @@ -100,12 +100,6 @@ public: int getFAdviseOptions() const { return _fAdviseOptions; } void setFAdviseOptions(int options) { _fAdviseOptions = options; } - /** - * Return path separator string. This will yield "/" on UNIX systems. - * @return pointer to path separator character string - */ - static const char *GetPathSeparator() { return "/"; } - /** * Constructor. A filename could be supplied at this point, or specified * later using @ref SetFileName() or @ref Open(). @@ -343,12 +337,6 @@ public: */ int64_t getSize() const { return const_cast(this)->GetSize(); } - /** - * Return the time when file was last modified. - * @return time of last modification - */ - virtual vespalib::system_time getModificationTime() = 0; - /** * Delete the file. This method requires that the file is * currently not opened. @@ -413,10 +401,6 @@ public: bool useSyncWrites() const { return _syncWritesEnabled; } - /** - * Set the write chunk size used in WriteBuf. - */ - void setChunkSize(size_t chunkSize) { _chunkSize = chunkSize; } size_t getChunkSize() const { return _chunkSize; } /** @@ -652,14 +636,12 @@ public: */ class FastOS_DirectoryScanInterface { -private: - FastOS_DirectoryScanInterface(const FastOS_DirectoryScanInterface&); - FastOS_DirectoryScanInterface& operator= (const FastOS_DirectoryScanInterface&); - protected: std::string _searchPath; public: + FastOS_DirectoryScanInterface(const FastOS_DirectoryScanInterface&) = delete; + FastOS_DirectoryScanInterface& operator= (const FastOS_DirectoryScanInterface&) = delete; /** * Constructor. @@ -676,13 +658,6 @@ public: */ virtual ~FastOS_DirectoryScanInterface(); - /** - * Get search path. - * This is an internal copy of the path specified in the constructor. - * @return Search path string. - */ - const char *GetSearchPath () { return _searchPath.c_str(); } - /** * Read the next entry in the directory scan. Failure indicates * that there are no more entries. If the call is successful, @@ -726,14 +701,6 @@ public: * @return A pointer to the recently read directory entry. */ virtual const char *GetName() = 0; - - /** - * Check whether the creation of a directory scan succeeded or - * failed (e.g. due to resource constraints). - * - * return True if the directory scan is valid. - */ - virtual bool IsValidScan() const = 0; }; #ifdef __linux__ diff --git a/vespalib/src/vespa/fastos/unix_file.cpp b/vespalib/src/vespa/fastos/unix_file.cpp index 8f7d4eb8bec..417129c99b3 100644 --- a/vespalib/src/vespa/fastos/unix_file.cpp +++ b/vespalib/src/vespa/fastos/unix_file.cpp @@ -344,21 +344,6 @@ FastOS_UNIX_File::GetSize() return fileSize; } - -vespalib::system_time -FastOS_UNIX_File::getModificationTime() -{ - struct stat stbuf{}; - assert(IsOpened()); - - int res = fstat(_filedes, &stbuf); - assert(res == 0); - (void) res; - - return vespalib::system_time(vespalib::duration(stbuf.st_mtim.tv_sec*1000*1000*1000 + stbuf.st_mtim.tv_nsec)); -} - - bool FastOS_UNIX_File::Delete(const char *name) { @@ -581,10 +566,3 @@ FastOS_UNIX_DirectoryScan::GetName() return static_cast(_dp->d_name); } - - -bool -FastOS_UNIX_DirectoryScan::IsValidScan() const -{ - return _dir != nullptr; -} diff --git a/vespalib/src/vespa/fastos/unix_file.h b/vespalib/src/vespa/fastos/unix_file.h index b19279caa05..3d1f6b9db3f 100644 --- a/vespalib/src/vespa/fastos/unix_file.h +++ b/vespalib/src/vespa/fastos/unix_file.h @@ -82,7 +82,6 @@ public: bool SetPosition(int64_t desiredPosition) override; int64_t GetPosition() override; int64_t GetSize() override; - vespalib::system_time getModificationTime() override; bool Delete() override; [[nodiscard]] bool Sync() override; bool SetSize(int64_t newSize) override; @@ -103,9 +102,6 @@ public: class FastOS_UNIX_DirectoryScan : public FastOS_DirectoryScanInterface { private: - FastOS_UNIX_DirectoryScan(const FastOS_UNIX_DirectoryScan&); - FastOS_UNIX_DirectoryScan& operator=(const FastOS_UNIX_DirectoryScan&); - bool _statRun; bool _isDirectory; bool _isRegular; @@ -126,5 +122,4 @@ public: bool IsDirectory() override; bool IsRegular() override; const char *GetName() override; - bool IsValidScan() const override; }; -- cgit v1.2.3