mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
Fix DeadLock in FdManager::ChangeEntityToTempPath (#2455)
commit e3b50ad
introduce smart pointer to manage FdEntity
But in ChangeEntityToTempPath, we should not destroy the entity.
We should move the entry to the temp ky
Signed-off-by: liubingrun <liubr1@chinatelecom.cn>
This commit is contained in:
parent
3864f58c22
commit
ccdcccd44c
@ -775,7 +775,7 @@ bool FdManager::Close(FdEntity* ent, int fd)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FdManager::ChangeEntityToTempPath(FdEntity* ent, const char* path)
|
||||
bool FdManager::ChangeEntityToTempPath(const FdEntity* ent, const char* path)
|
||||
{
|
||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||
|
||||
@ -783,8 +783,10 @@ bool FdManager::ChangeEntityToTempPath(FdEntity* ent, const char* path)
|
||||
if(iter->second.get() == ent){
|
||||
std::string tmppath;
|
||||
FdManager::MakeRandomTempPath(path, tmppath);
|
||||
iter->second.reset(ent);
|
||||
break;
|
||||
// Move the entry to the new key
|
||||
fent[tmppath] = std::move(iter->second);
|
||||
iter = fent.erase(iter);
|
||||
return true;
|
||||
}else{
|
||||
++iter;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class FdManager
|
||||
FdEntity* OpenExistFdEntity(const char* path, int& fd, int flags = O_RDONLY);
|
||||
void Rename(const std::string &from, const std::string &to);
|
||||
bool Close(FdEntity* ent, int fd);
|
||||
bool ChangeEntityToTempPath(FdEntity* ent, const char* path);
|
||||
bool ChangeEntityToTempPath(const FdEntity* ent, const char* path);
|
||||
void CleanupCacheDir();
|
||||
|
||||
bool CheckAllCache();
|
||||
|
Loading…
Reference in New Issue
Block a user