From 918d6ac603246fbc153fdbdad897c317d554c78c Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Wed, 30 Oct 2024 16:39:32 +0000 Subject: [PATCH] Fixed a bug when changing fdentity to a temporary path --- src/fdcache.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/fdcache.cpp b/src/fdcache.cpp index ae0545f747..bce77b9cc5 100644 --- a/src/fdcache.cpp +++ b/src/fdcache.cpp @@ -751,8 +751,25 @@ bool FdManager::Close(FdEntity* ent, int fd) bool FdManager::ChangeEntityToTempPath(std::shared_ptr ent, const char* path) { + // [NOTE] + // If the path element does not exist in fent, it may be because a cache directory + // has not been specified, or FdEntity::NoCacheLoadAndPost has already been called. + // In these cases, the path element(=ent) has already been registered as a TempPath + // element from fent, so there is no need to register ent in the except_fent map. + // (Processing with UpdateEntityToTempPath should not be performed.) + // + { + const std::lock_guard lock(FdManager::fd_manager_lock); + + if(fent.cend() == fent.find(path)){ + S3FS_PRN_INFO("Already path(%s) element does not exist in fent map.", path); + return false; + } + } + const std::lock_guard lock(FdManager::except_entmap_lock); except_fent[path] = std::move(ent); + return true; }