diff --git a/src/io/file_io.h b/src/io/file_io.h index 6e27e716e..ea797b801 100644 --- a/src/io/file_io.h +++ b/src/io/file_io.h @@ -32,6 +32,13 @@ struct FileReader { } } + ~FileReader() { + if (fd_ != -1) { + close(fd_); + fd_ = -1; + } + } + int descriptor() const { return fd_; @@ -62,13 +69,8 @@ struct FileReader { return lseek(fd_, 0, SEEK_CUR); } - int - close() { - return ::close(fd_); - } - private: - int fd_; + int fd_ = -1; size_t size_; }; } // namespace knowhere diff --git a/thirdparty/hnswlib/hnswlib/hnswalg.h b/thirdparty/hnswlib/hnswlib/hnswalg.h index ac9e03de3..f1b0aafa9 100644 --- a/thirdparty/hnswlib/hnswlib/hnswalg.h +++ b/thirdparty/hnswlib/hnswlib/hnswalg.h @@ -892,8 +892,6 @@ class HierarchicalNSW : public AlgorithmInterface { input.read(linkLists_[i], linkListSize); } } - - input.close(); } void