From 0372b477f08e3d7649b4610b492ec6509a8b92a2 Mon Sep 17 00:00:00 2001 From: dhinton Date: Mon, 20 May 2002 09:44:56 +0000 Subject: ChangeLogTag:Mon May 20 09:39:32 UTC 2002 Don Hinton --- ChangeLog | 25 ++++++++++++++++++++++++- ChangeLogs/ChangeLog-02a | 25 ++++++++++++++++++++++++- ChangeLogs/ChangeLog-03a | 25 ++++++++++++++++++++++++- ace/DLL.cpp | 37 ++++++++++++++++++++++++++++++++++--- ace/DLL.h | 8 +++++++- ace/Parse_Node.cpp | 23 ++++++++--------------- ace/Parse_Node.h | 7 ++----- ace/Service_Object.cpp | 7 ++++--- ace/Service_Object.h | 4 ++-- 9 files changed, 129 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c36cf5f70b..9ab1079a9be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Mon May 20 09:39:32 UTC 2002 Don Hinton + + * ace/Service_Object.{h,cpp}: + + Changed dll_ member variable to be a ACE_DLL instead + of a pointer to one. Reduces heap usages. + + Temporarily turned on tracing for this file. + + * ace/Parse_Node.{h,cpp}: + + Reverted ACE_Location_Node to contain an ACE_DLL, not a pointer. + And altered new get_dll() method to return a const reference to + the contained member. + + * ace/DLL.{h,cpp}: + + Added copy constructor that takes ownership of the dll. Added + open_mode_ variable so that the newly constructed copy can call + open() with the same parameters as the original. + + Temporarily turned on tracing for this file. + Sun May 19 09:20:15 UTC 2002 Don Hinton * tests/Makefile: @@ -17,7 +40,7 @@ Sun May 19 09:20:15 UTC 2002 Don Hinton * bin/generate_export_file.pl: Added code to generate library specifig XXX_TRACE macros - that use the new ACE_TRACE_IMPL macor below based on + that use the new ACE_TRACE_IMPL macro below based on XXX_NTRACE. This mimics the normal ACE_TRACE usage, but makes it possible to easily control tracing on a per library basis. diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a index 1c36cf5f70b..9ab1079a9be 100644 --- a/ChangeLogs/ChangeLog-02a +++ b/ChangeLogs/ChangeLog-02a @@ -1,3 +1,26 @@ +Mon May 20 09:39:32 UTC 2002 Don Hinton + + * ace/Service_Object.{h,cpp}: + + Changed dll_ member variable to be a ACE_DLL instead + of a pointer to one. Reduces heap usages. + + Temporarily turned on tracing for this file. + + * ace/Parse_Node.{h,cpp}: + + Reverted ACE_Location_Node to contain an ACE_DLL, not a pointer. + And altered new get_dll() method to return a const reference to + the contained member. + + * ace/DLL.{h,cpp}: + + Added copy constructor that takes ownership of the dll. Added + open_mode_ variable so that the newly constructed copy can call + open() with the same parameters as the original. + + Temporarily turned on tracing for this file. + Sun May 19 09:20:15 UTC 2002 Don Hinton * tests/Makefile: @@ -17,7 +40,7 @@ Sun May 19 09:20:15 UTC 2002 Don Hinton * bin/generate_export_file.pl: Added code to generate library specifig XXX_TRACE macros - that use the new ACE_TRACE_IMPL macor below based on + that use the new ACE_TRACE_IMPL macro below based on XXX_NTRACE. This mimics the normal ACE_TRACE usage, but makes it possible to easily control tracing on a per library basis. diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 1c36cf5f70b..9ab1079a9be 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,26 @@ +Mon May 20 09:39:32 UTC 2002 Don Hinton + + * ace/Service_Object.{h,cpp}: + + Changed dll_ member variable to be a ACE_DLL instead + of a pointer to one. Reduces heap usages. + + Temporarily turned on tracing for this file. + + * ace/Parse_Node.{h,cpp}: + + Reverted ACE_Location_Node to contain an ACE_DLL, not a pointer. + And altered new get_dll() method to return a const reference to + the contained member. + + * ace/DLL.{h,cpp}: + + Added copy constructor that takes ownership of the dll. Added + open_mode_ variable so that the newly constructed copy can call + open() with the same parameters as the original. + + Temporarily turned on tracing for this file. + Sun May 19 09:20:15 UTC 2002 Don Hinton * tests/Makefile: @@ -17,7 +40,7 @@ Sun May 19 09:20:15 UTC 2002 Don Hinton * bin/generate_export_file.pl: Added code to generate library specifig XXX_TRACE macros - that use the new ACE_TRACE_IMPL macor below based on + that use the new ACE_TRACE_IMPL macro below based on XXX_NTRACE. This mimics the normal ACE_TRACE usage, but makes it possible to easily control tracing on a per library basis. diff --git a/ace/DLL.cpp b/ace/DLL.cpp index 87baa0eddb4..fdab8873b31 100644 --- a/ace/DLL.cpp +++ b/ace/DLL.cpp @@ -9,6 +9,9 @@ ACE_RCSID(ace, DLL, "$Id$") +#undef ACE_TRACE +#define ACE_TRACE(X) ACE_TRACE_IMPL(X) + // Default constructor. Also, by default, the object will be closed // before it is destroyed. @@ -16,10 +19,36 @@ sig_atomic_t ACE_DLL::open_called_ = 0; ACE_DLL::ACE_DLL (int close_on_destruction) : handle_ (ACE_SHLIB_INVALID_HANDLE), + open_mode_ (0), dll_name_ (0), close_on_destruction_ (close_on_destruction), last_error_ (0) { + ACE_TRACE ("ACE_DLL::ACE_DLL (int)"); +} + +ACE_DLL::ACE_DLL (const ACE_DLL &rhs) +{ + ACE_TRACE ("ACE_DLL::ACE_DLL (const ACE_DLL &)"); + // Have to do this since open() calls close()... + this->handle_ = ACE_SHLIB_INVALID_HANDLE; + this->dll_name_ = 0; + this->last_error_ = 0; + + if (rhs.handle_ != ACE_SHLIB_INVALID_HANDLE) + { + // Since we call ACE_OS::dlopen(), we always assume the responsibility + // of calling ACE_OS::dlclose() + this->open (rhs.dll_name_, rhs.open_mode_, 1); + } + else + { + // Make copy without calling open. + this->open_mode_ = rhs.open_mode_; + this->dll_name_ = ACE::strnew (rhs.dll_name_); + this->close_on_destruction_ = 1; + this->last_error_ = ACE::strnew (rhs.last_error_); + } } // If the library name and the opening mode are specified than on @@ -29,6 +58,7 @@ ACE_DLL::ACE_DLL (const ACE_TCHAR *dll_name, int open_mode, int close_on_destruction) : handle_ (ACE_SHLIB_INVALID_HANDLE), + open_mode_ (open_mode), dll_name_ (0), close_on_destruction_ (close_on_destruction), last_error_ (0) @@ -84,9 +114,10 @@ ACE_DLL::open (const ACE_TCHAR *dll_filename, ACE::strdelete (this->dll_name_); this->dll_name_ = ACE::strnew (dll_filename); - // Reset the flag + // Reset the flags + this->open_mode_ = open_mode; this->close_on_destruction_ = close_on_destruction; - + // Find out where the library is ACE_TCHAR dll_pathname[MAXPATHLEN + 1]; @@ -98,7 +129,7 @@ ACE_DLL::open (const ACE_TCHAR *dll_filename, // The ACE_SHLIB_HANDLE object is obtained. this->handle_ = ACE_OS::dlopen (dll_pathname, - open_mode); + open_mode_); #if defined (AIX) if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) diff --git a/ace/DLL.h b/ace/DLL.h index 83c125b7327..5501db0d2e2 100644 --- a/ace/DLL.h +++ b/ace/DLL.h @@ -55,6 +55,9 @@ public: int open_mode = ACE_DEFAULT_SHLIB_MODE, int close_on_destruction = 1); + /// Copy constructor. + ACE_DLL (const ACE_DLL &); + /** * This method opens and dynamically links . The default * mode is , which loads identifier symbols but not the @@ -106,6 +109,9 @@ private: /// This is a handle to the DLL. ACE_SHLIB_HANDLE handle_; + /// Open mode. + int open_mode_; + /// Keep track of the name of the loaded dll, so it can be used /// to remove framework components, singletons that live in the dll, /// prior to unloading the dll in the close() method. @@ -125,7 +131,7 @@ private: ACE_TCHAR *last_error_; // = Disallow copying and assignment since we don't handle these. - ACE_UNIMPLEMENTED_FUNC (ACE_DLL (const ACE_DLL &)) + //ACE_UNIMPLEMENTED_FUNC (ACE_DLL (const ACE_DLL &)) ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_DLL &)) }; diff --git a/ace/Parse_Node.cpp b/ace/Parse_Node.cpp index 09a830e26c8..08db977524c 100644 --- a/ace/Parse_Node.cpp +++ b/ace/Parse_Node.cpp @@ -329,26 +329,19 @@ ACE_Location_Node::dump (void) const ACE_Location_Node::ACE_Location_Node (void) : pathname_ (0), - delete_dll_ (0), - dll_ (0), symbol_ (0) { ACE_TRACE ("ACE_Location_Node::ACE_Location_Node"); - ACE_NEW (dll_, ACE_DLL); } ACE_Location_Node::~ACE_Location_Node (void) { ACE_TRACE ("ACE_Location_Node::~ACE_Location_Node"); - if (this->delete_dll_) - delete dll_; } -ACE_DLL * +const ACE_DLL & ACE_Location_Node::dll (void) { - // Now caller owns dll. - this->delete_dll_ = 0; return this->dll_; } @@ -356,7 +349,7 @@ ACE_SHLIB_HANDLE ACE_Location_Node::handle (void) { ACE_TRACE ("ACE_Location_Node::handle"); - return this->dll_->get_handle (0); // Caller does not own the handle + return this->dll_.get_handle (0); // Caller does not own the handle } const ACE_TCHAR * @@ -392,11 +385,11 @@ ACE_Location_Node::open_dll (void) { ACE_TRACE ("ACE_Location_Node::open_dll"); - if (-1 == this->dll_->open (this->pathname ())) + if (-1 == this->dll_.open (this->pathname ())) { ace_yyerrno++; - ACE_TCHAR *errmsg = this->dll_->error (); + ACE_TCHAR *errmsg = this->dll_.error (); ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL::open failed for %s: %s\n"), this->pathname (), @@ -433,12 +426,12 @@ ACE_Object_Node::symbol (ACE_Service_Object_Exterminator *) { ACE_TCHAR *object_name = ACE_const_cast (ACE_TCHAR *, this->object_name_); - this->symbol_ = this->dll_->symbol (object_name); + this->symbol_ = this->dll_.symbol (object_name); if (this->symbol_ == 0) { ace_yyerrno++; - ACE_TCHAR *errmsg = this->dll_->error (); + ACE_TCHAR *errmsg = this->dll_.error (); ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL::symbol failed for object %s: %s\n"), object_name, @@ -502,7 +495,7 @@ ACE_Function_Node::symbol (ACE_Service_Object_Exterminator *gobbler) // close to (or, at least claim to conform with) the standard // did not complain about this as an illegal pointer conversion. long temp_ptr = - ACE_reinterpret_cast(long, this->dll_->symbol (function_name)); + ACE_reinterpret_cast(long, this->dll_.symbol (function_name)); func = ACE_reinterpret_cast(void *(*)(ACE_Service_Object_Exterminator *), temp_ptr); @@ -514,7 +507,7 @@ ACE_Function_Node::symbol (ACE_Service_Object_Exterminator *gobbler) { ace_yyerrno++; - ACE_TCHAR *errmsg = this->dll_->error (); + ACE_TCHAR *errmsg = this->dll_.error (); ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL::symbol failed for function %s: %s\n"), function_name, diff --git a/ace/Parse_Node.h b/ace/Parse_Node.h index c4de9061961..f8f2094e107 100644 --- a/ace/Parse_Node.h +++ b/ace/Parse_Node.h @@ -202,7 +202,7 @@ public: virtual void *symbol (ACE_Service_Object_Exterminator * = 0) = 0; virtual void set_symbol (void *h); ACE_SHLIB_HANDLE handle (void); - ACE_DLL *dll (void); + const ACE_DLL &dll (void); const ACE_TCHAR *pathname (void) const; void pathname (const ACE_TCHAR *h); int dispose (void) const; @@ -228,11 +228,8 @@ protected: */ int must_delete_; - /// Flag to determine if we should delete the dll. - int delete_dll_; - /// The open shared library. - ACE_DLL *dll_; + ACE_DLL dll_; /// Symbol that we've obtained from the shared library. void *symbol_; diff --git a/ace/Service_Object.cpp b/ace/Service_Object.cpp index 52283e3bdcc..64ee5fd2317 100644 --- a/ace/Service_Object.cpp +++ b/ace/Service_Object.cpp @@ -11,6 +11,9 @@ ACE_RCSID(ace, Service_Object, "$Id$") +#undef ACE_TRACE +#define ACE_TRACE(X) ACE_TRACE_IMPL(X) + ACE_ALLOC_HOOK_DEFINE(ACE_Service_Object) ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type) @@ -22,7 +25,7 @@ ACE_Service_Type::dump (void) const ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n, ACE_Service_Type_Impl *t, - ACE_DLL *dll, + const ACE_DLL &dll, int active) : name_ (0), type_ (t), @@ -40,8 +43,6 @@ ACE_Service_Type::~ACE_Service_Type (void) this->fini (); - delete dll_; - delete [] (ACE_TCHAR *) this->name_; } diff --git a/ace/Service_Object.h b/ace/Service_Object.h index 3cb9d5af50a..61346e44738 100644 --- a/ace/Service_Object.h +++ b/ace/Service_Object.h @@ -87,7 +87,7 @@ public: // = Initialization and termination methods. ACE_Service_Type (const ACE_TCHAR *n, ACE_Service_Type_Impl *o, - ACE_DLL *dll, + const ACE_DLL &dll, int active); ~ACE_Service_Type (void); @@ -126,7 +126,7 @@ private: const ACE_Service_Type_Impl *type_; /// ACE_DLL representing the shared object file (non-zero if dynamically linked). - ACE_DLL *dll_; + ACE_DLL dll_; /// 1 if svc is currently active, otherwise 0. int active_; -- cgit v1.2.1