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:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user