Merge remote-tracking branch 'upstream/issue#435'

This commit is contained in:
Takeshi Nakatani 2016-11-19 19:52:27 +00:00
commit 90eda81624

View File

@ -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 && !force_tmpfile && !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;