*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
// $Id: DLL_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $
|
||||
|
||||
#include "ace/DLL_Manager.h"
|
||||
|
||||
#include "ace/Log_Msg.h"
|
||||
#include "ace/ACE.h"
|
||||
#include "ace/Framework_Component.h"
|
||||
|
||||
#include "ace/Lib_Find.h"
|
||||
#include "ace/Object_Manager.h"
|
||||
#include "ace/SString.h"
|
||||
@@ -13,17 +10,12 @@
|
||||
#include "ace/Guard_T.h"
|
||||
#include "ace/OS_NS_dlfcn.h"
|
||||
#include "ace/OS_NS_string.h"
|
||||
|
||||
ACE_RCSID (ace,
|
||||
DLL_Manager,
|
||||
"DLL_Manager.cpp,v 4.23 2003/11/05 23:30:46 shuston Exp")
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
sig_atomic_t ACE_DLL_Handle::open_called_ = 0;
|
||||
|
||||
ACE_DLL_Handle::ACE_DLL_Handle (void)
|
||||
: refcount_ (0),
|
||||
dll_name_ (0),
|
||||
@@ -31,21 +23,18 @@ ACE_DLL_Handle::ACE_DLL_Handle (void)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Handle::ACE_DLL_Handle");
|
||||
}
|
||||
|
||||
ACE_DLL_Handle::~ACE_DLL_Handle (void)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Handle::~ACE_DLL_Handle");
|
||||
this->close (1);
|
||||
delete[] this->dll_name_;
|
||||
}
|
||||
|
||||
const ACE_TCHAR *
|
||||
ACE_DLL_Handle::dll_name (void) const
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Handle::dll_name");
|
||||
return this->dll_name_;
|
||||
}
|
||||
|
||||
int
|
||||
ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
int open_mode,
|
||||
@@ -53,7 +42,6 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Handle::open");
|
||||
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
|
||||
|
||||
if (this->dll_name_)
|
||||
{
|
||||
// Once dll_name_ has been set, it can't be changed..
|
||||
@@ -65,16 +53,13 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
ACE_TEXT ("tried to reopen %s with name %s\n"),
|
||||
this->dll_name_,
|
||||
dll_name));
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
this->dll_name_ = ACE::strnew (dll_name);
|
||||
|
||||
if (!this->open_called_)
|
||||
this->open_called_ = 1;
|
||||
|
||||
// If it hasn't been loaded yet, go ahead and do that now.
|
||||
if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
|
||||
{
|
||||
@@ -100,11 +85,9 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
*/
|
||||
ACE_Array<ACE_TString> dll_names;
|
||||
dll_names.max_size (10); // Decent guess to avoid realloc later
|
||||
|
||||
#if defined (ACE_MUST_HELP_DLOPEN_SEARCH_PATH)
|
||||
// Find out where the library is
|
||||
ACE_TCHAR dll_pathname[MAXPATHLEN + 1];
|
||||
|
||||
// Transform the pathname into the appropriate dynamic link library
|
||||
// by searching the ACE_LD_SEARCH_PATH.
|
||||
ACE::ldfind (dll_name,
|
||||
@@ -116,7 +99,6 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
#else
|
||||
this->get_dll_names (dll_name, dll_names);
|
||||
#endif
|
||||
|
||||
ACE_Array_Iterator<ACE_TString> name_iter (dll_names);
|
||||
ACE_TString *name = 0;
|
||||
while (name_iter.next (name))
|
||||
@@ -124,7 +106,6 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
// The ACE_SHLIB_HANDLE object is obtained.
|
||||
this->handle_ = ACE_OS::dlopen (name->c_str (),
|
||||
open_mode);
|
||||
|
||||
if (ACE::debug ())
|
||||
{
|
||||
ACE_DEBUG ((LM_DEBUG,
|
||||
@@ -137,10 +118,8 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
: ACE_TEXT ("failed")),
|
||||
this->error()->c_str()));
|
||||
}
|
||||
|
||||
if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one?
|
||||
break;
|
||||
|
||||
// If errno is ENOENT we just skip over this one,
|
||||
// anything else - like an undefined symbol, for
|
||||
// instance must be flagged here or the next error will
|
||||
@@ -155,7 +134,6 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
name->c_str (),
|
||||
errno,
|
||||
this->error ()->c_str ()));
|
||||
|
||||
#if defined (AIX)
|
||||
// AIX often puts the shared library file (most often named
|
||||
// shr.o) inside an archive library. If this is an archive
|
||||
@@ -169,7 +147,6 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
aix_pathname[name->length ()] = '\0';
|
||||
ACE_OS::strcat (aix_pathname, ACE_TEXT ("(shr.o)"));
|
||||
open_mode |= RTLD_MEMBER;
|
||||
|
||||
if (ACE::debug ())
|
||||
{
|
||||
ACE_DEBUG ((LM_DEBUG,
|
||||
@@ -182,11 +159,9 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
: "failed"),
|
||||
this->error()->c_str()));
|
||||
}
|
||||
|
||||
this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode);
|
||||
if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)
|
||||
break;
|
||||
|
||||
// If errno is ENOENT we just skip over this one, anything
|
||||
// else - like an undefined symbol, for instance
|
||||
// must be flagged here or the next error will mask it.
|
||||
@@ -201,13 +176,10 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
name->c_str (),
|
||||
errno,
|
||||
this->error ()->c_str ()));
|
||||
|
||||
}
|
||||
#endif /* AIX */
|
||||
|
||||
name_iter.advance ();
|
||||
}
|
||||
|
||||
if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
|
||||
{
|
||||
if (ACE::debug ())
|
||||
@@ -216,14 +188,11 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
ACE_TEXT ("Invalid handle error: %s\n"),
|
||||
this->dll_name_,
|
||||
this->error ()->c_str ()));
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++this->refcount_;
|
||||
|
||||
if (ACE::debug ())
|
||||
ACE_DEBUG ((LM_DEBUG,
|
||||
ACE_TEXT ("ACE (%P|%t) DLL_Handle::open - %s (%d), refcount=%d\n"),
|
||||
@@ -233,21 +202,17 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ACE_DLL_Handle::close (int unload)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Handle::close");
|
||||
|
||||
int retval = 0;
|
||||
ACE_SHLIB_HANDLE h = ACE_SHLIB_INVALID_HANDLE;
|
||||
|
||||
// Only hold the lock until it comes time to dlclose() the DLL. Closing
|
||||
// the DLL can cause further shutdowns as DLLs and their dependents are
|
||||
// unloaded.
|
||||
{
|
||||
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
|
||||
|
||||
// Since we don't actually unload the dll as soon as the refcount
|
||||
// reaches zero, we need to make sure we don't decrement it below
|
||||
// zero.
|
||||
@@ -255,7 +220,6 @@ ACE_DLL_Handle::close (int unload)
|
||||
--this->refcount_;
|
||||
else
|
||||
this->refcount_ = 0;
|
||||
|
||||
if (ACE::debug ())
|
||||
ACE_DEBUG ((LM_DEBUG,
|
||||
ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ")
|
||||
@@ -263,7 +227,6 @@ ACE_DLL_Handle::close (int unload)
|
||||
this->dll_name_,
|
||||
this->handle_,
|
||||
this->refcount_));
|
||||
|
||||
if (this->refcount_ == 0 &&
|
||||
this->handle_ != ACE_SHLIB_INVALID_HANDLE &&
|
||||
unload == 1)
|
||||
@@ -274,45 +237,37 @@ ACE_DLL_Handle::close (int unload)
|
||||
ACE_TEXT ("Unloading %s (handle=%d)\n"),
|
||||
this->dll_name_,
|
||||
this->handle_));
|
||||
|
||||
// First remove any associated Framework Components.
|
||||
ACE_Framework_Repository *frPtr= ACE_Framework_Repository::instance ();
|
||||
if (frPtr)
|
||||
{
|
||||
frPtr->remove_dll_components (this->dll_name_);
|
||||
}
|
||||
|
||||
h = this->handle_;
|
||||
this->handle_ = ACE_SHLIB_INVALID_HANDLE;
|
||||
}
|
||||
} // Release lock_ here
|
||||
|
||||
if (h != ACE_SHLIB_INVALID_HANDLE)
|
||||
{
|
||||
retval = ACE_OS::dlclose (h);
|
||||
|
||||
if (retval != 0 && ACE::debug ())
|
||||
ACE_ERROR ((LM_ERROR,
|
||||
ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ")
|
||||
ACE_TEXT ("Failed with: \"%s\".\n"),
|
||||
this->error ()->c_str ()));
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
sig_atomic_t
|
||||
ACE_DLL_Handle::refcount (void) const
|
||||
{
|
||||
return this->refcount_;
|
||||
}
|
||||
|
||||
void *
|
||||
ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Handle::symbol");
|
||||
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
|
||||
|
||||
ACE_Auto_Array_Ptr <ACE_TCHAR> auto_name (ACE::ldname (sym_name));
|
||||
// handle_ can be invalid especially when ACE_DLL_Handle resigned ownership
|
||||
// BTW. Handle lifecycle management is a little crazy in ACE
|
||||
@@ -323,7 +278,6 @@ ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors)
|
||||
#else
|
||||
void *sym = ACE_OS::dlsym (this->handle_, auto_name.get ());
|
||||
#endif
|
||||
|
||||
// Linux says that the symbol could be null and that it isn't an
|
||||
// error. So you should check the error message also, but since
|
||||
// null symbols won't do us much good anyway, let's still report
|
||||
@@ -336,38 +290,31 @@ ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors)
|
||||
ACE_TEXT (" failed with \"%s\".\n"),
|
||||
auto_name.get (),
|
||||
this->error ()->c_str ()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
return sym;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ACE_SHLIB_HANDLE
|
||||
ACE_DLL_Handle::get_handle (int become_owner)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Handle::get_handle");
|
||||
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
|
||||
|
||||
if (this->refcount_ == 0 && become_owner != 0)
|
||||
{
|
||||
if (ACE::debug ())
|
||||
ACE_ERROR ((LM_ERROR,
|
||||
ACE_TEXT ("ACE (%P|%t) DLL_Handle::get_handle: ")
|
||||
ACE_TEXT ("cannot become owner, refcount == 0.\n")));
|
||||
|
||||
return ACE_SHLIB_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
ACE_SHLIB_HANDLE handle = this->handle_;
|
||||
|
||||
if (become_owner != 0)
|
||||
{
|
||||
if (--this->refcount_ == 0)
|
||||
this->handle_ = ACE_SHLIB_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (ACE::debug ())
|
||||
ACE_DEBUG ((LM_DEBUG,
|
||||
ACE_TEXT ("ACE (%P|%t) ACE_DLL_Handle::get_handle: ")
|
||||
@@ -375,12 +322,9 @@ ACE_DLL_Handle::get_handle (int become_owner)
|
||||
this->handle_ == ACE_SHLIB_INVALID_HANDLE ?
|
||||
ACE_TEXT ("invalid") : ACE_TEXT ("valid"),
|
||||
this->refcount_));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
// This method is used return the last error of a library operation.
|
||||
|
||||
auto_ptr <ACE_TString>
|
||||
ACE_DLL_Handle::error (void)
|
||||
{
|
||||
@@ -390,7 +334,6 @@ ACE_DLL_Handle::error (void)
|
||||
(new ACE_TString (error ? error : ACE_TEXT ("no error")));
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
|
||||
ACE_Array<ACE_TString> &try_names)
|
||||
@@ -399,7 +342,6 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
|
||||
// proper prefixes and/or suffixes to the specified dll_name.
|
||||
ACE_TString base (dll_name);
|
||||
ACE_TString base_dir, base_file, base_suffix;
|
||||
|
||||
// 1. Separate the dll_name into the dir part and the file part. We
|
||||
// only decorate the file part to determine the names to try loading.
|
||||
ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);
|
||||
@@ -410,7 +352,6 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
|
||||
}
|
||||
else
|
||||
base_file = base;
|
||||
|
||||
// 2. Locate the file suffix, if there is one. Move the '.' and the
|
||||
// suffix to base_suffix.
|
||||
if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos)
|
||||
@@ -418,7 +359,6 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
|
||||
base_suffix = base_file.substr (pos);
|
||||
base_file = base_file.substr (0, pos);
|
||||
}
|
||||
|
||||
// 3. Build the combinations to try for this platform.
|
||||
// Try these combinations:
|
||||
// - name with decorator and platform's suffix appended (if not supplied)
|
||||
@@ -442,7 +382,6 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
|
||||
#endif
|
||||
ACE_TString suffix (ACE_DLL_SUFFIX);
|
||||
ACE_TString prefix (ACE_DLL_PREFIX);
|
||||
|
||||
for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)
|
||||
{
|
||||
ACE_TString try_this;
|
||||
@@ -478,7 +417,6 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
|
||||
try_this = dll_name;
|
||||
break;
|
||||
}
|
||||
|
||||
if (try_this.length ())
|
||||
{
|
||||
try_names.size (j + 1);
|
||||
@@ -487,18 +425,14 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
// Pointer to the Singleton instance.
|
||||
ACE_DLL_Manager *ACE_DLL_Manager::instance_ = 0;
|
||||
|
||||
|
||||
ACE_DLL_Manager *
|
||||
ACE_DLL_Manager::instance (int size)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::instance");
|
||||
|
||||
if (ACE_DLL_Manager::instance_ == 0)
|
||||
{
|
||||
// Perform Double-Checked Locking Optimization.
|
||||
@@ -511,22 +445,17 @@ ACE_DLL_Manager::instance (int size)
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
return ACE_DLL_Manager::instance_;
|
||||
}
|
||||
|
||||
void
|
||||
ACE_DLL_Manager::close_singleton (void)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::close_singleton");
|
||||
|
||||
ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
|
||||
*ACE_Static_Object_Lock::instance ()));
|
||||
|
||||
delete ACE_DLL_Manager::instance_;
|
||||
ACE_DLL_Manager::instance_ = 0;
|
||||
}
|
||||
|
||||
ACE_DLL_Manager::ACE_DLL_Manager (int size)
|
||||
: handle_vector_ (0),
|
||||
current_size_ (0),
|
||||
@@ -534,30 +463,25 @@ ACE_DLL_Manager::ACE_DLL_Manager (int size)
|
||||
unload_policy_ (ACE_DLL_UNLOAD_POLICY_PER_DLL)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::ACE_DLL_Manager");
|
||||
|
||||
if (this->open (size) != 0 && ACE::debug ())
|
||||
ACE_ERROR ((LM_ERROR,
|
||||
ACE_TEXT ("ACE_DLL_Manager ctor failed to allocate ")
|
||||
ACE_TEXT ("handle_vector_.\n")));
|
||||
}
|
||||
|
||||
ACE_DLL_Manager::~ACE_DLL_Manager (void)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::~ACE_DLL_Manager");
|
||||
|
||||
if (this->close () != 0 && ACE::debug ())
|
||||
ACE_ERROR ((LM_ERROR,
|
||||
ACE_TEXT ("ACE_DLL_Manager dtor failed to close ")
|
||||
ACE_TEXT ("properly.\n")));
|
||||
}
|
||||
|
||||
ACE_DLL_Handle *
|
||||
ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name,
|
||||
int open_mode,
|
||||
ACE_SHLIB_HANDLE handle)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::open_dll");
|
||||
|
||||
ACE_DLL_Handle *temp_handle = 0;
|
||||
ACE_DLL_Handle *dll_handle = 0;
|
||||
{
|
||||
@@ -570,12 +494,10 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name,
|
||||
ACE_NEW_RETURN (temp_handle,
|
||||
ACE_DLL_Handle,
|
||||
0);
|
||||
|
||||
dll_handle = temp_handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dll_handle)
|
||||
{
|
||||
if (dll_handle->open (dll_name, open_mode, handle) != 0)
|
||||
@@ -586,11 +508,9 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name,
|
||||
ACE_TEXT ("ACE_DLL_Manager::open_dll: Could not ")
|
||||
ACE_TEXT ("open dll %s.\n"),
|
||||
dll_name));
|
||||
|
||||
delete temp_handle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Add the handle to the vector only if the dll is successfully
|
||||
// opened.
|
||||
if (temp_handle != 0)
|
||||
@@ -600,45 +520,36 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name,
|
||||
++this->current_size_;
|
||||
}
|
||||
}
|
||||
|
||||
return dll_handle;
|
||||
}
|
||||
|
||||
int
|
||||
ACE_DLL_Manager::close_dll (const ACE_TCHAR *dll_name)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::close_dll");
|
||||
ACE_DLL_Handle *handle = 0;
|
||||
|
||||
{
|
||||
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
|
||||
handle = this->find_dll (dll_name);
|
||||
}
|
||||
|
||||
if (handle)
|
||||
{
|
||||
return this->unload_dll (handle, 0);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
u_long
|
||||
ACE_DLL_Manager::unload_policy (void) const
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::unload_policy");
|
||||
return this->unload_policy_;
|
||||
}
|
||||
|
||||
void
|
||||
ACE_DLL_Manager::unload_policy (u_long unload_policy)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::unload_policy");
|
||||
ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_));
|
||||
|
||||
u_long old_policy = this->unload_policy_;
|
||||
this->unload_policy_ = unload_policy;
|
||||
|
||||
// If going from LAZY to EAGER or from PER_DLL to PER_PROCESS|EAGER,
|
||||
// call close(1) on all the ACE_DLL_Handle objects with refcount == 0
|
||||
// which will force those that are still loaded to be unloaded.
|
||||
@@ -657,30 +568,23 @@ ACE_DLL_Manager::unload_policy (u_long unload_policy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ACE_DLL_Manager::open (int size)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::open");
|
||||
|
||||
ACE_DLL_Handle **temp = 0;
|
||||
|
||||
ACE_NEW_RETURN (temp,
|
||||
ACE_DLL_Handle *[size],
|
||||
-1);
|
||||
|
||||
this->handle_vector_ = temp;
|
||||
this->total_size_ = size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ACE_DLL_Manager::close (void)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::close");
|
||||
|
||||
int force_close = 1;
|
||||
|
||||
if (this->handle_vector_ != 0)
|
||||
{
|
||||
// Delete components in reverse order.
|
||||
@@ -695,34 +599,28 @@ ACE_DLL_Manager::close (void)
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] this->handle_vector_;
|
||||
this->handle_vector_ = 0;
|
||||
this->current_size_ = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ACE_DLL_Handle *
|
||||
ACE_DLL_Manager::find_dll (const ACE_TCHAR *dll_name) const
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::find_dll");
|
||||
|
||||
for (int i = 0; i < this->current_size_; i++)
|
||||
if (this->handle_vector_[i] &&
|
||||
ACE_OS::strcmp (this->handle_vector_[i]->dll_name (), dll_name) == 0)
|
||||
{
|
||||
return this->handle_vector_[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload)
|
||||
{
|
||||
ACE_TRACE ("ACE_DLL_Manager::unload_dll");
|
||||
|
||||
if (dll_handle)
|
||||
{
|
||||
int unload = force_unload;
|
||||
@@ -739,7 +637,6 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload)
|
||||
{
|
||||
// Declare the type of the symbol:
|
||||
typedef int (*dll_unload_policy)(void);
|
||||
|
||||
void * const unload_policy_ptr =
|
||||
dll_handle->symbol (ACE_TEXT ("_get_dll_unload_policy"), 1);
|
||||
#if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
|
||||
@@ -749,10 +646,8 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload)
|
||||
intptr_t const temp_p =
|
||||
reinterpret_cast<intptr_t> (unload_policy_ptr);
|
||||
#endif
|
||||
|
||||
dll_unload_policy const the_policy =
|
||||
reinterpret_cast<dll_unload_policy> (temp_p);
|
||||
|
||||
if (the_policy != 0)
|
||||
unload = ACE_BIT_DISABLED (the_policy (),
|
||||
ACE_DLL_UNLOAD_POLICY_LAZY);
|
||||
@@ -761,13 +656,11 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload)
|
||||
ACE_DLL_UNLOAD_POLICY_LAZY);
|
||||
}
|
||||
}
|
||||
|
||||
if (dll_handle->close (unload) != 0)
|
||||
{
|
||||
if (ACE::debug ())
|
||||
ACE_ERROR ((LM_ERROR,
|
||||
ACE_TEXT ("ACE_DLL_Manager::unload error.\n")));
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -777,12 +670,9 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload)
|
||||
ACE_ERROR ((LM_ERROR,
|
||||
ACE_TEXT ("ACE_DLL_Manager::unload_dll called with ")
|
||||
ACE_TEXT ("null pointer.\n")));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ACE_END_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user