mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-09-30 02:09:02 +00:00
Merge pull request #1092 from liuyongqing/master
fix coredump caused by fd_manager_lock locking
This commit is contained in:
commit
850a813171
@ -2125,59 +2125,58 @@ FdEntity* FdManager::Open(const char* path, headers_t* pmeta, off_t size, time_t
|
|||||||
}
|
}
|
||||||
bool close = false;
|
bool close = false;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
{
|
|
||||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
|
||||||
|
|
||||||
// search in mapping by key(path)
|
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||||
fdent_map_t::iterator iter = fent.find(string(path));
|
|
||||||
|
|
||||||
if(fent.end() == iter && !force_tmpfile && !FdManager::IsCacheDir()){
|
// search in mapping by key(path)
|
||||||
// If the cache directory is not specified, s3fs opens a temporary file
|
fdent_map_t::iterator iter = fent.find(string(path));
|
||||||
// when the file is opened.
|
|
||||||
// Then if it could not find a entity in map for the file, s3fs should
|
if(fent.end() == iter && !force_tmpfile && !FdManager::IsCacheDir()){
|
||||||
// search a entity in all which opened the temporary file.
|
// If the cache directory is not specified, s3fs opens a temporary file
|
||||||
//
|
// when the file is opened.
|
||||||
for(iter = fent.begin(); iter != fent.end(); ++iter){
|
// Then if it could not find a entity in map for the file, s3fs should
|
||||||
if((*iter).second && (*iter).second->IsOpen() && 0 == strcmp((*iter).second->GetPath(), path)){
|
// search a entity in all which opened the temporary file.
|
||||||
break; // found opened fd in mapping
|
//
|
||||||
}
|
for(iter = fent.begin(); iter != fent.end(); ++iter){
|
||||||
|
if((*iter).second && (*iter).second->IsOpen() && 0 == strcmp((*iter).second->GetPath(), path)){
|
||||||
|
break; // found opened fd in mapping
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(fent.end() != iter){
|
if(fent.end() != iter){
|
||||||
// found
|
// found
|
||||||
ent = (*iter).second;
|
ent = (*iter).second;
|
||||||
ent->Dup();
|
ent->Dup();
|
||||||
close = true;
|
close = true;
|
||||||
|
|
||||||
}else if(is_create){
|
}else if(is_create){
|
||||||
// not found
|
// not found
|
||||||
string cache_path;
|
string cache_path;
|
||||||
if(!force_tmpfile && !FdManager::MakeCachePath(path, cache_path, true)){
|
if(!force_tmpfile && !FdManager::MakeCachePath(path, cache_path, true)){
|
||||||
S3FS_PRN_ERR("failed to make cache path for object(%s).", path);
|
S3FS_PRN_ERR("failed to make cache path for object(%s).", path);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
// make new obj
|
|
||||||
ent = new FdEntity(path, cache_path.c_str());
|
|
||||||
|
|
||||||
if(!cache_path.empty()){
|
|
||||||
// using cache
|
|
||||||
fent[string(path)] = ent;
|
|
||||||
}else{
|
|
||||||
// not using cache, so the key of fdentity is set not really existing path.
|
|
||||||
// (but not strictly unexisting path.)
|
|
||||||
//
|
|
||||||
// [NOTE]
|
|
||||||
// The reason why this process here, please look at the definition of the
|
|
||||||
// comments of NOCACHE_PATH_PREFIX_FORM symbol.
|
|
||||||
//
|
|
||||||
string tmppath;
|
|
||||||
FdManager::MakeRandomTempPath(path, tmppath);
|
|
||||||
fent[tmppath] = ent;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
// make new obj
|
||||||
|
ent = new FdEntity(path, cache_path.c_str());
|
||||||
|
|
||||||
|
if(!cache_path.empty()){
|
||||||
|
// using cache
|
||||||
|
fent[string(path)] = ent;
|
||||||
|
}else{
|
||||||
|
// not using cache, so the key of fdentity is set not really existing path.
|
||||||
|
// (but not strictly unexisting path.)
|
||||||
|
//
|
||||||
|
// [NOTE]
|
||||||
|
// The reason why this process here, please look at the definition of the
|
||||||
|
// comments of NOCACHE_PATH_PREFIX_FORM symbol.
|
||||||
|
//
|
||||||
|
string tmppath;
|
||||||
|
FdManager::MakeRandomTempPath(path, tmppath);
|
||||||
|
fent[tmppath] = ent;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open
|
// open
|
||||||
|
Loading…
Reference in New Issue
Block a user