summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2020-03-17 18:44:03 +0100
committerGitHub <noreply@github.com>2020-03-17 18:44:03 +0100
commitc2bb0005cf63ab06f9e991418fdee5b22a3c8db8 (patch)
treeab8697e05489c434d2e63583d4170161f96aec59
parent6a3c9dec68cbd1b86883619a66efbd037ca0003a (diff)
parentafb9f6bac9051b77180178d541b9ae1555717e1f (diff)
downloadATCD-c2bb0005cf63ab06f9e991418fdee5b22a3c8db8.tar.gz
Merge pull request #1058 from jwillemsen/jwi-dlopenerrorlogging
Log all dlopen errors into the error stack coming from ACE_OS::dlopen
-rw-r--r--ACE/ace/DLL.cpp2
-rw-r--r--ACE/ace/DLL_Manager.cpp107
-rw-r--r--ACE/ace/DLL_Manager.h14
3 files changed, 40 insertions, 83 deletions
diff --git a/ACE/ace/DLL.cpp b/ACE/ace/DLL.cpp
index 4fed8ba8db6..998a52a8827 100644
--- a/ACE/ace/DLL.cpp
+++ b/ACE/ace/DLL.cpp
@@ -276,7 +276,7 @@ ACE_DLL::set_handle (ACE_SHLIB_HANDLE handle,
{
ACE_TRACE ("ACE_DLL::set_handle");
- // Create a unique name. Note that this name is only quaranteed
+ // Create a unique name. Note that this name is only guaranteed
// to be unique for the life of this object.
ACE_TCHAR temp[ACE_UNIQUE_NAME_LEN];
ACE_OS::unique_name (this, temp, ACE_UNIQUE_NAME_LEN);
diff --git a/ACE/ace/DLL_Manager.cpp b/ACE/ace/DLL_Manager.cpp
index 68dda37c08a..8151097896e 100644
--- a/ACE/ace/DLL_Manager.cpp
+++ b/ACE/ace/DLL_Manager.cpp
@@ -62,7 +62,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
if (ACE::debug ())
ACELIB_ERROR ((LM_ERROR,
ACE_TEXT ("ACE (%P|%t) DLL_Handle::open: error, ")
- ACE_TEXT ("tried to reopen %s with name %s\n"),
+ ACE_TEXT ("tried to reopen <%s> with name <%s>\n"),
this->dll_name_,
dll_name));
@@ -121,11 +121,9 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
for (ACE_Array_Iterator<ACE_TString> name_iter (dll_names);
name_iter.next (name); name_iter.advance ())
{
- if (this->open_i (name->c_str (), open_mode))
+ if (this->open_i (name->c_str (), open_mode, errors))
break;
- this->log_error (name->c_str (), errors);
-
#if defined (AIX)
# define SHR_O ACE_TEXT("(shr.o)")
# define SHR_O_LEN (sizeof (SHR_O) / sizeof(ACE_TCHAR) - 1)
@@ -161,34 +159,22 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
if (this->open_i (aix_pathname, open_mode))
break;
-
- this->log_error (aix_pathname, errors);
}
#endif /* AIX */
}
if (this->handle_ == ACE_SHLIB_INVALID_HANDLE)
{
- if (errors || ACE::debug ())
+ if (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 (\"%s\"): ")
- ACE_TEXT ("Invalid handle error: %s\n"),
- this->dll_name_,
- errtmp.c_str ()));
- }
+ this->error (errtmp);
+ ACELIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open (\"%s\"): ")
+ ACE_TEXT ("Invalid handle error: %s\n"),
+ this->dll_name_,
+ errtmp.c_str ()));
}
-
return -1;
}
}
@@ -198,7 +184,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name,
if (ACE::debug ())
ACELIB_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ACE (%P|%t) DLL_Handle::open - %s (%d), refcount=%d\n"),
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open - <%s> (%d), refcount=%d\n"),
this->dll_name_,
this->handle_,
this->refcount_));
@@ -231,7 +217,7 @@ ACE_DLL_Handle::close (int unload)
if (ACE::debug ())
ACELIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ")
- ACE_TEXT ("%s (handle=%d, refcount=%d)\n"),
+ ACE_TEXT ("<%s> (handle=%d, refcount=%d)\n"),
this->dll_name_,
this->handle_,
this->refcount_));
@@ -243,7 +229,7 @@ ACE_DLL_Handle::close (int unload)
if (ACE::debug ())
ACELIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("ACE (%P|%t) DLL_Handle::close: ")
- ACE_TEXT ("Unloading %s (handle=%d)\n"),
+ ACE_TEXT ("Unloading <%s> (handle=%d)\n"),
this->dll_name_,
this->handle_));
@@ -268,7 +254,7 @@ ACE_DLL_Handle::close (int unload)
ACE_TString err;
ACELIB_ERROR ((LM_ERROR,
ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ")
- ACE_TEXT ("Failed with: \"%s\".\n"),
+ ACE_TEXT ("Failed with: <%s>\n"),
this->error (err).c_str ()));
}
}
@@ -316,8 +302,8 @@ ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, bool ignore_errors, ACE_TStri
if (ACE::debug ())
ACELIB_ERROR ((LM_ERROR,
- ACE_TEXT ("ACE (%P|%t) DLL_Handle::symbol (\"%s\") ")
- ACE_TEXT (" failed with \"%s\".\n"),
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::symbol <%s>")
+ ACE_TEXT (" failed with <%s>\n"),
auto_name.get (),
error.c_str ()));
@@ -364,13 +350,15 @@ ACE_DLL_Handle::get_handle (bool become_owner)
}
// This method is used return the last error of a library operation.
-
ACE_TString &
ACE_DLL_Handle::error (ACE_TString &err)
{
ACE_TRACE ("ACE_DLL_Handle::error");
const ACE_TCHAR *error = ACE_OS::dlerror ();
- err = (error ? error : ACE_TEXT ("no error"));
+ if (error)
+ {
+ err = error;
+ }
return err;
}
@@ -472,59 +460,34 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
}
bool
-ACE_DLL_Handle::open_i (const ACE_TCHAR *dll_name, int open_mode)
+ACE_DLL_Handle::open_i (const ACE_TCHAR *dll_name, int open_mode, ERROR_STACK* errors)
{
// The ACE_SHLIB_HANDLE object is obtained.
this->handle_ = ACE_OS::dlopen (dll_name, open_mode);
- if (ACE::debug ())
+ if (errors || 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)
+ this->error (err);
+ if (errors && err.length () > 0)
{
- errors->push (this->error (errtmp));
+ errors->push (err);
}
-
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"),
+ ACELIB_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ACE (%P|%t) DLL_Handle::open_i ")
+ ACE_TEXT ("<%s>, 0x%x) -> <%s>: <%s>\n"),
dll_name,
- ACE_ERRNO_GET,
- errtmp.c_str ()));
+ open_mode,
+ ((this->handle_ != ACE_SHLIB_INVALID_HANDLE)
+ ? ACE_TEXT ("succeeded")
+ : ACE_TEXT ("failed")),
+ err.c_str ()));
}
}
+
+ return this->handle_ != ACE_SHLIB_INVALID_HANDLE;
}
/******************************************************************/
@@ -626,7 +589,7 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name,
if (ACE::debug ())
ACELIB_ERROR ((LM_ERROR,
ACE_TEXT ("ACE (%P|%t) DLL_Manager::open_dll: Could not ")
- ACE_TEXT ("open dll %s.\n"),
+ ACE_TEXT ("open dll <%s>\n"),
dll_name));
delete temp_handle;
diff --git a/ACE/ace/DLL_Manager.h b/ACE/ace/DLL_Manager.h
index 6c17ee7572c..66ca5f09911 100644
--- a/ACE/ace/DLL_Manager.h
+++ b/ACE/ace/DLL_Manager.h
@@ -54,7 +54,7 @@ class ACE_Export ACE_DLL_Handle
{
public:
/// Error stack. Fixed size should suffice. Ignores any errors exceeding the size.
- typedef ACE_Fixed_Stack < ACE_TString, 10 > ERROR_STACK;
+ typedef ACE_Fixed_Stack <ACE_TString, 10> ERROR_STACK;
/// Default construtor.
ACE_DLL_Handle (void);
@@ -164,18 +164,12 @@ private:
* @a dll_name is first loaded
* @li @c RTLD_GLOBAL: makes symbols available for relocation
* processing of any other DLLs.
- * @retval false On failure
- * @retval true On success.
- */
- bool open_i (const ACE_TCHAR *dll_name, int open_mode);
-
- /**
- * This method logs error of opening the DLL.
- * @param dll_name The filename or path of the DLL to load.
* @param errors Optional address of an error stack to collect any errors
* encountered.
+ * @retval false On failure
+ * @retval true On success
*/
- void log_error (const ACE_TCHAR *dll_name, ERROR_STACK *errors);
+ bool open_i (const ACE_TCHAR *dll_name, int open_mode, ERROR_STACK* errors);
/// Disallow copying and assignment since we don't handle them.
ACE_DLL_Handle (const ACE_DLL_Handle &);