From 716baada22f23e123cecf1ce031200e36b860183 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Mon, 10 Oct 2016 12:16:09 +0000 Subject: [PATCH] Testing patch codes for issue#435 --- src/fdcache.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/fdcache.cpp b/src/fdcache.cpp index 92f6403..ac82198 100644 --- a/src/fdcache.cpp +++ b/src/fdcache.cpp @@ -1963,8 +1963,23 @@ FdEntity* FdManager::Open(const char* path, headers_t* pmeta, ssize_t size, time } AutoLock auto_lock(&FdManager::fd_manager_lock); + // search in mapping by key(path) fdent_map_t::iterator iter = fent.find(string(path)); - FdEntity* ent; + + if(fent.end() == iter && !FdManager::IsCacheDir()){ + // If the cache directory is not specified, s3fs opens a temporary file + // when the file is opened. + // Then if it could not find a entity in map for the file, s3fs should + // search a entity in all which opened the temporary file. + // + for(iter = fent.begin(); iter != fent.end(); ++iter){ + if((*iter).second && (*iter).second->IsOpen()){ + break; // found opened fd in mapping + } + } + } + + FdEntity* ent; if(fent.end() != iter){ // found ent = (*iter).second;