diff --git a/repertory/librepertory/include/drives/directory_cache.hpp b/repertory/librepertory/include/drives/directory_cache.hpp index babf6bd6..1278d5e1 100644 --- a/repertory/librepertory/include/drives/directory_cache.hpp +++ b/repertory/librepertory/include/drives/directory_cache.hpp @@ -22,12 +22,10 @@ #ifndef REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_ #define REPERTORY_INCLUDE_DRIVES_DIRECTORY_CACHE_HPP_ -#include "utils/single_thread_service_base.hpp" - namespace repertory { class directory_iterator; -class directory_cache final : public single_thread_service_base { +class directory_cache final { public: using execute_callback = std::function; @@ -35,13 +33,11 @@ private: struct open_directory final { std::shared_ptr iterator; std::vector handles; - std::chrono::system_clock::time_point last_update{ - std::chrono::system_clock::now()}; }; public: - directory_cache() : single_thread_service_base("directory_cache") {} - ~directory_cache() override = default; + directory_cache() = default; + ~directory_cache() = default; directory_cache(const directory_cache &) = delete; directory_cache(directory_cache &&) = delete; @@ -51,17 +47,13 @@ public: private: std::unordered_map directory_lookup_; std::recursive_mutex directory_mutex_; - std::unique_ptr refresh_thread_; - -protected: - void service_function() override; public: void execute_action(const std::string &api_path, const execute_callback &execute); - [[nodiscard]] auto - get_directory(std::uint64_t handle) -> std::shared_ptr; + [[nodiscard]] auto get_directory(std::uint64_t handle) + -> std::shared_ptr; auto remove_directory(const std::string &api_path) -> std::shared_ptr; diff --git a/repertory/librepertory/src/drives/directory_cache.cpp b/repertory/librepertory/src/drives/directory_cache.cpp index e55430d9..a15f23ce 100644 --- a/repertory/librepertory/src/drives/directory_cache.cpp +++ b/repertory/librepertory/src/drives/directory_cache.cpp @@ -84,33 +84,6 @@ void directory_cache::remove_directory(std::uint64_t handle) { } } -void directory_cache::service_function() { - unique_recur_mutex_lock directory_lock(directory_mutex_); - auto lookup = directory_lookup_; - directory_lock.unlock(); - - for (const auto &item : lookup) { - if (std::chrono::duration_cast( - std::chrono::system_clock::now() - item.second.last_update) >= - 120s) { - directory_lock.lock(); - directory_lookup_.erase(item.first); - directory_lock.unlock(); - } - } - - if (get_stop_requested()) { - return; - } - - unique_mutex_lock shutdown_lock(get_mutex()); - if (get_stop_requested()) { - return; - } - - get_notify().wait_for(shutdown_lock, 15s); -} - void directory_cache::set_directory( const std::string &api_path, std::uint64_t handle, std::shared_ptr iterator) { diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index d7f891ce..1fca30ee 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -270,10 +270,6 @@ void fuse_drive::stop_all() { provider_.stop(); - if (directory_cache_) { - directory_cache_->stop(); - } - directory_cache_.reset(); eviction_.reset(); server_.reset(); @@ -298,11 +294,11 @@ void fuse_drive::destroy_impl(void *ptr) { stop_all(); - event_system::instance().raise(get_mount_location()); - config_.save(); fuse_base::destroy_impl(ptr); + + event_system::instance().raise(get_mount_location()); } auto fuse_drive::fallocate_impl(std::string /*api_path*/, int mode, @@ -589,7 +585,6 @@ void *fuse_drive::init_impl(struct fuse_conn_info *conn) { } directory_cache_ = std::make_unique(); - directory_cache_->start(); server_->start(); if (not provider_.start(