summaryrefslogtreecommitdiff
path: root/ACE/ace/DLL_Manager.cpp
diff options
context:
space:
mode:
authorLike Ma <likemartinma@gmail.com>2019-02-05 00:01:09 +0800
committerLike Ma <likemartinma@gmail.com>2019-02-22 14:16:25 +0800
commit2d7180fbf501ca2f901bf843520196e10c87fd1b (patch)
tree57317c4dd37b9ffc57fd86935aebabee4c33e4fd /ACE/ace/DLL_Manager.cpp
parentb584d571ee82182fb39a572f24fd8083e50eb0ec (diff)
downloadATCD-2d7180fbf501ca2f901bf843520196e10c87fd1b.tar.gz
Refactor ACE_DLL_Handle::open
Diffstat (limited to 'ACE/ace/DLL_Manager.cpp')
-rw-r--r--ACE/ace/DLL_Manager.cpp157
1 files changed, 62 insertions, 95 deletions
diff --git a/ACE/ace/DLL_Manager.cpp b/ACE/ace/DLL_Manager.cpp
index a3ab8df7aa8..260ba863699 100644
--- a/ACE/ace/DLL_Manager.cpp
+++ b/ACE/ace/DLL_Manager.cpp
@@ -117,58 +117,14 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
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))
+ for (ACE_Array_Iterator<ACE_TString> name_iter (dll_names);
+ name_iter.next (name); name_iter.advance ())
{
- // The ACE_SHLIB_HANDLE object is obtained.
- this->handle_ = ACE_OS::dlopen (name->c_str (),
- open_mode);
-
- if (ACE::debug ())
- {
- ACE_TString err;
- ACELIB_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
- ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"),
- name->c_str (),
- open_mode,
- ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)
- ? ACE_TEXT ("succeeded")
- : ACE_TEXT ("failed")),
- this->error (err).c_str()));
- }
-
- if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one?
+ if (this->open_i (name->c_str (), open_mode))
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.
- // @TODO: If we've found our DLL _and_ it's
- // broken, should we continue at all?
- if ((errno != ENOENT) && (errors || ACE::debug ()))
- {
- ACE_TString errtmp;
- if (errors)
- {
- errors->push (this->error (errtmp));
- }
-
- if (ACE::debug ())
- {
- if (!errors)
- this->error (errtmp);
- ACELIB_ERROR ((LM_ERROR,
- ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
- ACE_TEXT ("(\'%s\') failed, errno=")
- ACE_TEXT ("%d: <%s>\n"),
- name->c_str (),
- ACE_ERRNO_GET,
- errtmp.c_str ()));
- }
- }
+ this->log_error (name->c_str (), errors);
#if defined (AIX)
# define SHR_O ACE_TEXT("(shr.o)")
@@ -203,57 +159,12 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
}
open_mode |= RTLD_MEMBER;
- this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode);
-
- if (ACE::debug ())
- {
- ACE_TString err;
- ACELIB_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
- ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"),
- aix_pathname,
- open_mode,
- (this->handle_ != ACE_SHLIB_INVALID_HANDLE
- ? ACE_TEXT ("succeeded")
- : ACE_TEXT ("failed")),
- this->error(err).c_str()));
- }
-
- if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)
+ if (this->open_i (name->c_str (), open_mode))
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.
- //
- // @TODO: If we've found our DLL _and_ it's broken,
- // should we continue at all?
- if ((errno != ENOENT) && (errors || ACE::debug ()))
- {
- ACE_TString errtmp;
- if (errors)
- {
- errors->push (this->error (errtmp));
- }
-
- if (ACE::debug ())
- {
- if (!errors)
- this->error (errtmp);
- ACELIB_ERROR ((LM_ERROR,
- ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
- ACE_TEXT ("(\'%s\') failed, errno=")
- ACE_TEXT ("%d: <%s>\n"),
- name->c_str (),
- ACE_ERRNO_GET,
- errtmp.c_str ()));
- }
- }
-
+ this->log_error (name->c_str (), errors);
}
#endif /* AIX */
-
- name_iter.advance ();
}
if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
@@ -560,6 +471,62 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
return;
}
+bool
+ACE_DLL_Handle::open_i (const ACE_TCHAR *dll_name, int open_mode)
+{
+ // The ACE_SHLIB_HANDLE object is obtained.
+ this->handle_ = ACE_OS::dlopen (dll_name, open_mode);
+
+ if (ACE::debug ())
+ {
+ ACE_TString err;
+ ACELIB_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
+ ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"),
+ dll_name,
+ open_mode,
+ ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)
+ ? ACE_TEXT ("succeeded")
+ : ACE_TEXT ("failed")),
+ this->error (err).c_str()));
+ }
+
+ return this->handle_ != ACE_SHLIB_INVALID_HANDLE;
+}
+
+void
+ACE_DLL_Handle::log_error (const ACE_TCHAR *dll_name, ERROR_STACK *errors)
+{
+ // 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.
+ //
+ // @TODO: If we've found our DLL _and_ it's broken,
+ // should we continue at all?
+ if (errno != ENOENT && (errors || ACE::debug ()))
+ {
+ ACE_TString errtmp;
+ if (errors)
+ {
+ errors->push (this->error (errtmp));
+ }
+
+ if (ACE::debug ())
+ {
+ if (!errors)
+ this->error (errtmp);
+
+ ACELIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ")
+ ACE_TEXT ("(\'%s\') failed, errno=")
+ ACE_TEXT ("%d: <%s>\n"),
+ dll_name,
+ ACE_ERRNO_GET,
+ errtmp.c_str ()));
+ }
+ }
+}
+
/******************************************************************/
// Pointer to the Singleton instance.