summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-04-07 15:35:32 +0000
committeriliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-04-07 15:35:32 +0000
commit36d5afb08545f9f26261cb8a5f9eb0efd90be781 (patch)
tree156773325eaea9cfd56f0a7f945a383248c20c98
parent7d897ce4b216009527bcdef333ae4c779a5a7b2c (diff)
downloadATCD-36d5afb08545f9f26261cb8a5f9eb0efd90be781.tar.gz
Merged revisions 81261 via svnmerge from
https://svn.dre.vanderbilt.edu/DOC/Middleware/trunk/ACE ........ r81261 | iliyan | 2008-04-07 10:23:38 -0500 (Mon, 07 Apr 2008) | 1 line ChangeLogTag: Mon Apr 7 15:21:38 UTC 2008 Iliyan Jeliazkov <iliyan@ociweb.com> ........
-rw-r--r--ACE/ChangeLog36
-rw-r--r--ACE/ace/Service_Config.cpp53
-rw-r--r--ACE/ace/Service_Config.h26
-rw-r--r--ACE/ace/Service_Config.inl5
-rw-r--r--ACE/ace/Svc_Conf.y46
-rw-r--r--ACE/ace/Svc_Conf_y.cpp56
-rw-r--r--ACE/tests/Bug_2980_Regression_Test.cpp8
7 files changed, 79 insertions, 151 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index cf4654f6419..9f7cb6fb5c0 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,39 @@
+Mon Apr 7 15:21:38 UTC 2008 Iliyan Jeliazkov <iliyan@ociweb.com>
+
+ This the second part of the SC refatoring. It builds on top of
+ the intrusive refcounting mechanism introduced earlier to improve
+ design and eliminate memory issues (leaks, SEGV on shutdown)
+
+ * ace/Service_Config.cpp (open_i,ACE_Service_Config):
+
+ Moved the implicit configuration file handling from open_i to
+ the SG instance. Eliminated close_svcs() by incorporating its
+ functionality in close().
+
+ * ace/Service_Config.inl:
+ * ace/Service_Config.h (ACE_Service_Config_Guard,ACE_Service_Config):
+
+ Removing the inheritance relationship between Service Config and
+ Service Gestalt. To simplify the memory management, SC becomes an
+ interface to the actual configuration data managed by SG. Coupled
+ with the reference counting of SG instances, this ensures correct
+ memory management in multi-threaded environments where both the
+ TSS and the user code may trigger SG finalization.
+
+ Introducing ACE_Threading_Helper to simplify TSS management
+ (RAII idiom). Changed ACE_Service_Config_Guard to use the new
+ smart pointer for SG. Doxygen comments cleanup.
+
+ * ace/Svc_Conf.y:
+ * ace/Svc_Conf_y.cpp:
+
+ Fixing unused function definition
+
+ * tests/Bug_2980_Regression_Test.cpp:
+
+ Updating the test to prevent it from breaking vxWorks builds
+ which appear to lack a declaration for dlopen()
+
Sun Apr 6 01:53:13 UTC 2008 Iliyan Jeliazkov <iliyan@ociweb.com>
* ace/Service_Gestalt.cpp:
diff --git a/ACE/ace/Service_Config.cpp b/ACE/ace/Service_Config.cpp
index 00e8ca00f3a..eeb4d005681 100644
--- a/ACE/ace/Service_Config.cpp
+++ b/ACE/ace/Service_Config.cpp
@@ -15,9 +15,7 @@
# include "ace/Sig_Adapter.h"
#endif /* !ACE_LACKS_UNIX_SIGNALS */
-#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_time.h"
-#include "ace/OS_NS_unistd.h"
#include "ace/Get_Opt.h"
#include "ace/ARGV.h"
#include "ace/Log_Msg.h"
@@ -42,7 +40,7 @@ typedef ACE_Unmanaged_Singleton<ACE_Service_Config,
/// ctor
-ACE_Service_Config_Guard::ACE_Service_Config_Guard (ACE_Service_Gestalt* psg)
+ACE_Service_Config_Guard::ACE_Service_Config_Guard (ACE_Service_Gestalt * psg)
: saved_ (ACE_Service_Config::current ())
{
if (ACE::debug ())
@@ -194,11 +192,11 @@ ACE_Service_Config::open_i (const ACE_TCHAR program_name[],
// forwarding to it, so we don't have to increment here.
if (instance_->is_opened_ != 0)
return instance_->open_i (program_name,
- logger_key,
- ignore_static_svcs,
- ignore_default_svc_conf_file,
- ignore_debug_flag);
-
+ logger_key,
+ ignore_static_svcs,
+ ignore_default_svc_conf_file,
+ ignore_debug_flag);
+
// Check for things we need to do on a per-process basis and which
// may not be safe, or wise to do an a per instance basis
@@ -280,15 +278,15 @@ ACE_Service_Config::open_i (const ACE_TCHAR program_name[],
return -1;
return instance_->open_i (program_name,
- logger_key,
- ignore_static_svcs,
- ignore_default_svc_conf_file,
- ignore_debug_flag);
+ logger_key,
+ ignore_static_svcs,
+ ignore_default_svc_conf_file,
+ ignore_debug_flag);
}
/// Return the global configuration instance. Always returns the same
/// instance
-ACE_Service_Config*
+ACE_Service_Config *
ACE_Service_Config::singleton (void)
{
return ACE_SERVICE_CONFIG_SINGLETON::instance ();
@@ -339,37 +337,35 @@ ACE_Service_Config::ACE_Service_Config (bool ignore_static_svcs,
int signum)
{
ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
-
+
// TODO: Need to find a more customizable way of instantiating the
// gestalt but perhaps we should leave this out untill such
// customizations are identified.
ACE_Service_Gestalt* tmp = 0;
ACE_NEW_NORETURN (tmp,
ACE_Service_Gestalt (size, false, ignore_static_svcs));
-
+
this->instance_ = tmp;
this->threadkey_.set (tmp);
-
+
ACE_Service_Config::signum_ = signum;
}
-
-
ACE_Service_Config::ACE_Service_Config (const ACE_TCHAR program_name[],
const ACE_TCHAR *logger_key)
{
ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
-
+
// TODO: Need to find a more customizable way of instantiating the
// gestalt but perhaps we should leave this out untill such
// customizations are identified.
ACE_Service_Gestalt* tmp = 0;
ACE_NEW_NORETURN (tmp,
ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false));
-
+
this->instance_ = tmp;
this->threadkey_.set (tmp);
-
+
if (this->open (program_name,
logger_key) == -1 && errno != ENOENT)
{
@@ -509,7 +505,6 @@ ACE_Service_Config::create_service_type_impl (const ACE_TCHAR *name,
// Signal handling API to trigger dynamic reconfiguration.
-
void
ACE_Service_Config::handle_signal (int sig,
siginfo_t *,
@@ -524,8 +519,7 @@ ACE_Service_Config::handle_signal (int sig,
ACE_Service_Config::reconfig_occurred_ = 1;
}
-// Trigger the reconfiguration process.
-
+// Trigger reconfiguration to re-read configuration files.
void
ACE_Service_Config::reconfigure (void)
{
@@ -585,16 +579,7 @@ ACE_Service_Config::fini_svcs (void)
return result;
}
-
-// Called when terminating a thread.
-template<> void
-ACE_TSS <ACE_Service_Gestalt>::cleanup (void*)
-{
- printf ("// (%x) cleanup\n", (int)ACE_OS::thr_self ());
-}
-
-// Perform user-specified close activities and remove dynamic memory.
-
+/// Perform user-specified close activities and remove dynamic memory.
ACE_Service_Config::~ACE_Service_Config (void)
{
ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config");
diff --git a/ACE/ace/Service_Config.h b/ACE/ace/Service_Config.h
index 57c004e66c4..14d505fdfdc 100644
--- a/ACE/ace/Service_Config.h
+++ b/ACE/ace/Service_Config.h
@@ -271,11 +271,11 @@ protected:
static ACE_Service_Config* singleton (void);
/**
- * Mutator to set the "global" instance. Intended for use by helper
- * classes like @see ACE_Service_Config_Guard. Stack-based instances
- * of it can be used to temporarily change which Gestalt is seen as
- * global by any static initializer (especially those in DLLs loaded
- * at run-time).
+ * Mutator for the currently active configuration context instance
+ * (gestalt). Intended for use by helper classes like @see
+ * ACE_Service_Config_Guard. Stack-based instances can be used to
+ * temporarily change which gestalt is seen as global by static
+ * initializers (especially those in DLLs loaded at run-time).
*/
static void current (ACE_Service_Gestalt*);
@@ -546,16 +546,16 @@ protected:
protected:
- // @deprecated
- // Process service configuration requests that were provided on the
- // command-line. Returns the number of errors that occurred.
+ /// @deprecated
+ /// Process service configuration requests that were provided on the
+ /// command-line. Returns the number of errors that occurred.
static int process_commandline_directives (void);
#if (ACE_USES_CLASSIC_SVC_CONF == 1)
- // @deprecated
- // This is the implementation function that process_directives()
- // and process_directive() both call. Returns the number of errors
- // that occurred.
+ /// @deprecated
+ /// This is the implementation function that process_directives()
+ /// and process_directive() both call. Returns the number of errors
+ /// that occurred.
static int process_directives_i (ACE_Svc_Conf_Param *param);
#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
@@ -622,7 +622,7 @@ private:
class ACE_Export ACE_Service_Config_Guard
{
public:
- ACE_Service_Config_Guard (ACE_Service_Gestalt*);
+ ACE_Service_Config_Guard (ACE_Service_Gestalt* psg);
~ACE_Service_Config_Guard (void);
private:
diff --git a/ACE/ace/Service_Config.inl b/ACE/ace/Service_Config.inl
index cc6a32ae225..bd888087c48 100644
--- a/ACE/ace/Service_Config.inl
+++ b/ACE/ace/Service_Config.inl
@@ -45,7 +45,6 @@ ACE_Service_Config::open (int argc,
// Handle the command-line options intended for the
// ACE_Service_Config.
-
ACE_INLINE int
ACE_Service_Config::parse_args (int argc, ACE_TCHAR *argv[])
{
@@ -54,7 +53,7 @@ ACE_Service_Config::parse_args (int argc, ACE_TCHAR *argv[])
/// Return the global configuration instance. Allways returns the same
/// instance
-ACE_INLINE ACE_Service_Gestalt*
+ACE_INLINE ACE_Service_Gestalt *
ACE_Service_Config::global (void)
{
return ACE_Service_Config::singleton()->instance_.get ();
@@ -65,7 +64,7 @@ ACE_Service_Config::global (void)
/// occasions, it may be a different one. For example,
/// ACE_Service_Config_Guard provides a way of temporarily replacing
/// the "current" configuration instance in the context of a thread.
-ACE_INLINE ACE_Service_Gestalt*
+ACE_INLINE ACE_Service_Gestalt *
ACE_Service_Config::instance (void)
{
return ACE_Service_Config::current ();
diff --git a/ACE/ace/Svc_Conf.y b/ACE/ace/Svc_Conf.y
index 57734fd6a95..72f9d1d9860 100644
--- a/ACE/ace/Svc_Conf.y
+++ b/ACE/ace/Svc_Conf.y
@@ -23,10 +23,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Prototypes.
static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr,
- ACE_Service_Type const * sv,
- int & ace_yyerrno);
-
-static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr,
ACE_TCHAR const * svc_name,
int & ace_yyerrno);
@@ -344,48 +340,6 @@ ace_get_module (ACE_Service_Type const * sr,
return const_cast<ACE_Module_Type *> (mt);
}
-static ACE_Module_Type *
-ace_get_module (ACE_Service_Type const * sr,
- ACE_Service_Type const * sv,
- int & yyerrno)
-{
- ACE_Stream_Type const * const st =
- (sr == 0
- ? 0
- : static_cast<ACE_Stream_Type const *> (sr->type ()));
-
- ACE_Module_Type const * const mt =
- static_cast <ACE_Module_Type const *> (sv->type ());
-
- ACE_TCHAR const * const module_type_name =
- (mt ? mt->name () : ACE_TEXT ("(nil)"));
-
- if (sr == 0 || st == 0 || mt == 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("cannot locate Module_Type %s or STREAM_Type %s\n"),
- module_type_name,
- (sr ? sr->name () : ACE_TEXT ("(nil)"))));
- ++yyerrno;
- }
-
- // Make sure that the Module has the same name as the
- // Module_Type object from the svc.conf file.
- ACE_Module<ACE_SYNCH> * const mp =
- static_cast<ACE_Module<ACE_SYNCH> *> (mt ? mt->object () : 0);
-
- if (mp && ACE_OS::strcmp (mp->name (), module_type_name) != 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"),
- module_type_name,
- mp->name ()));
- mp->name (module_type_name);
- }
-
- return const_cast<ACE_Module_Type *> (mt);
-}
-
#if defined (SVC_CONF_Y_DEBUGGING)
// Main driver program.
diff --git a/ACE/ace/Svc_Conf_y.cpp b/ACE/ace/Svc_Conf_y.cpp
index a5f25db32a9..e99941fead9 100644
--- a/ACE/ace/Svc_Conf_y.cpp
+++ b/ACE/ace/Svc_Conf_y.cpp
@@ -128,10 +128,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Prototypes.
static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr,
- ACE_Service_Type const * sv,
- int & ace_ace_yyerrno);
-
-static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr,
ACE_TCHAR const * svc_name,
int & ace_ace_yyerrno);
@@ -473,11 +469,11 @@ static const ace_yytype_int8 ace_yyrhs[] =
/* ACE_YYRLINE[ACE_YYN] -- source line where rule number ACE_YYN was defined. */
static const ace_yytype_uint16 ace_yyrline[] =
{
- 0, 62, 62, 71, 75, 79, 80, 81, 82, 83,
- 84, 88, 98, 105, 112, 119, 126, 130, 130, 137,
- 140, 147, 146, 155, 159, 167, 171, 174, 188, 197,
- 206, 228, 235, 239, 244, 250, 254, 258, 265, 269,
- 273, 280, 281, 285, 286, 287
+ 0, 58, 58, 67, 71, 75, 76, 77, 78, 79,
+ 80, 84, 94, 101, 108, 115, 122, 126, 126, 133,
+ 136, 143, 142, 151, 155, 163, 167, 170, 184, 193,
+ 202, 224, 231, 235, 240, 246, 250, 254, 261, 265,
+ 269, 276, 277, 281, 282, 283
};
#endif
@@ -1966,48 +1962,6 @@ ace_get_module (ACE_Service_Type const * sr,
return const_cast<ACE_Module_Type *> (mt);
}
-static ACE_Module_Type *
-ace_get_module (ACE_Service_Type const * sr,
- ACE_Service_Type const * sv,
- int & ace_yyerrno)
-{
- ACE_Stream_Type const * const st =
- (sr == 0
- ? 0
- : static_cast<ACE_Stream_Type const *> (sr->type ()));
-
- ACE_Module_Type const * const mt =
- static_cast <ACE_Module_Type const *> (sv->type ());
-
- ACE_TCHAR const * const module_type_name =
- (mt ? mt->name () : ACE_TEXT ("(nil)"));
-
- if (sr == 0 || st == 0 || mt == 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("cannot locate Module_Type %s or STREAM_Type %s\n"),
- module_type_name,
- (sr ? sr->name () : ACE_TEXT ("(nil)"))));
- ++ace_yyerrno;
- }
-
- // Make sure that the Module has the same name as the
- // Module_Type object from the svc.conf file.
- ACE_Module<ACE_SYNCH> * const mp =
- static_cast<ACE_Module<ACE_SYNCH> *> (mt ? mt->object () : 0);
-
- if (mp && ACE_OS::strcmp (mp->name (), module_type_name) != 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"),
- module_type_name,
- mp->name ()));
- mp->name (module_type_name);
- }
-
- return const_cast<ACE_Module_Type *> (mt);
-}
-
#if defined (SVC_CONF_Y_DEBUGGING)
// Main driver program.
diff --git a/ACE/tests/Bug_2980_Regression_Test.cpp b/ACE/tests/Bug_2980_Regression_Test.cpp
index 90beef77103..0cc4f5934a8 100644
--- a/ACE/tests/Bug_2980_Regression_Test.cpp
+++ b/ACE/tests/Bug_2980_Regression_Test.cpp
@@ -8,7 +8,7 @@
// platform-specific ones. Luckily, it is only Windows where this
// test has not been made to work yet ...
-#if !defined (WIN32)
+#if !(defined (WIN32) || defined (VXWORKS))
#include <dlfcn.h>
#include <pthread.h>
@@ -85,12 +85,12 @@ void * loadunloadDll(void *pp)
return 0;
}
-#endif /* !defined (ACE_WIN32) */
+#endif /* !(defined (WIN32) || defined (VXWORKS)) */
int main(int, char **)
{
-#if defined (WIN32)
+#if (defined (WIN32) || defined (VXWORKS))
printf ("Terminating because this test has not been designed "
"to run on platforms where WIN32 has been defined.\n");
@@ -132,7 +132,7 @@ int main(int, char **)
printf ("main - leaving\n");
-#endif /* defined (ACE_WIN32) */
+#endif /* (defined (WIN32) || defined (VXWORKS)) */
return 0;
}