Bug 2697

Summary: Suggestion for future DAnCE refactoring
Product: CIAO Reporter: Abdul Sowayan <abdullah.sowayan>
Component: DAnCEAssignee: Will Otte <wotte>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 0.5.3   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 2801, 3253    

Description Abdul Sowayan 2006-11-03 08:56:07 CST
I'm putting this in bugzilla so we can remember to do something about this 
when we refactor DAnCE.

---------------------------------
CIAO Version: 0.5.3

Area Affected:
$CIAO_ROOT\DAnCE\TargetManager\DomainDataManager.cpp

Descripton:

My apologies before hand if this is a dumb question. I didn't have much to 
research this. I came across the following code by accident:

//static variable
CIAO::DomainDataManager* CIAO::DomainDataManager::global_data_manager_ = 0;

CIAO::DomainDataManager * CIAO::DomainDataManager::create (CORBA::ORB_ptr orb,
                            ::Deployment::TargetManager_ptr target
                            )
{
  if (global_data_manager_ == 0)
    {
      global_data_manager_ = new DomainDataManager (orb , target);
    }
  return global_data_manager_;
}

The intent of the above code is to have a singleton, right? This code has the 
problem that two instances of DomainDataManager might be created, and only one 
destroyed, which will result in a memory leak.

We really should be using the Double-Checked Locking Optimization pattern to 
prevent the problem I described above from happening. This is similar to what 
is done in ACE_Thread_Manager::instance() method.

------------------------------------------------------

Hi Abdul,

   Right, I agree with you.  Will, can you please make sure we add this 
enhancement during the DAnCE refactoring?

Thanks,

        Doug
Comment 1 Johnny Willemsen 2006-11-03 12:41:35 CST
to will
Comment 2 Will Otte 2007-02-08 14:38:41 CST
Updated component.
Comment 3 Johnny Willemsen 2009-02-23 06:28:56 CST
duplicate of new bug that is based on svn head

*** This bug has been marked as a duplicate of bug 3590 ***