summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-07-31 01:03:21 +0000
committeriliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-07-31 01:03:21 +0000
commitcf879ca5aeb05f31e000380cb779e69137665ca8 (patch)
tree9317682b23f1b40050d2bcabdc26d03266c81ac2
parentb593ed6288112cace9a290999b7460dbb46ab845 (diff)
downloadATCD-cf879ca5aeb05f31e000380cb779e69137665ca8.tar.gz
ChangeLogTag: Tue Jul 31 00:50:49 UTC 2007 Iliyan Jeliazkov <iliyan@ociweb.com>
-rw-r--r--ACE/ChangeLog12
-rw-r--r--ACE/ace/Service_Config.cpp29
2 files changed, 31 insertions, 10 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 78b5a45a4ee..aa764a62a66 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,15 @@
+Tue Jul 31 00:50:49 UTC 2007 Iliyan Jeliazkov <iliyan@ociweb.com>
+
+ * ace/Service_Config.cpp:
+
+ By introducing a partial specialization of
+ ACE_TSS<ACE_Service_Config> we ensure that _if_ ACE_TSS::cleanup()
+ is called before ~ACE_Object_Manager(), the TSS pointer will not
+ clobber the ACE_Service_Config it points to. Resolves bugzilla
+ 2980. Thanks to Patrick Bennett <Patrick dot Bennett at inin dot
+ com> and Lothar Werzinger <lothar at tradescape dot biz> for
+ their input.
+
Mon Jul 30 23:51:07 UTC 2007 Steve Huston <shuston@riverace.com>
* ace/TP_Reactor.h: Documentation improvements, including clarification
diff --git a/ACE/ace/Service_Config.cpp b/ACE/ace/Service_Config.cpp
index 1751011af75..a5657f78094 100644
--- a/ACE/ace/Service_Config.cpp
+++ b/ACE/ace/Service_Config.cpp
@@ -362,18 +362,31 @@ ACE_Service_Config::resume (const ACE_TCHAR svc_name[])
return ACE_Service_Repository::instance ()->resume (svc_name);
}
-// Initialize the Service Repository. Note that this *must* be
-// performed in the constructor (rather than <open>) since otherwise
-// the repository will not be properly initialized to allow static
-// configuration of services...
+// This specialization allows us to have an ACE_TSS, which will _not_ perform
+// a delete on (ACE_Service_Gestalt*) p up on thread exit, when TSS is cleaned up.
+// Note that the tss_ member will be destroyed with the ACE_Object_Manager's
+// ACE_Service_Config singleton, so no leaks are introduced.
+template<> void
+ACE_TSS<ACE_Service_Gestalt>::cleanup (void* p)
+{
+ // We need this because the SC instance
+ // is really owned by the Object Manager and the TSS cleanup must not dispose of it
+ // prematurely.
+ // Naturally, things would be simpler, if we could avoid using the TSS alltogether
+ // but we need the ability to temporarily designate a different SC instance as the
+ // "default". So, the solution is a hybrid, or non-owner ACE_TSS.
+ // See ticket 2980 for a description of a test case where ACE_TSS::cleanup() is
+ // called before ~ACE_Object_Manager.
+}
+
ACE_Service_Config::ACE_Service_Config (int ignore_static_svcs,
size_t size,
int signum)
: ACE_Service_Gestalt (size, false, ignore_static_svcs)
+ , tss_ (this)
{
ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
- this->tss_.ts_object (this);
ACE_Service_Config::signum_ = signum;
}
@@ -438,10 +451,10 @@ ACE_Service_Config::create_service_type_impl (const ACE_TCHAR *name,
ACE_Service_Config::ACE_Service_Config (const ACE_TCHAR program_name[],
const ACE_TCHAR *logger_key)
: ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false)
+ , tss_ (this)
{
ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
- this->tss_.ts_object (this);
if (this->open (program_name,
logger_key) == -1 && errno != ENOENT)
{
@@ -545,10 +558,6 @@ ACE_Service_Config::fini_svcs (void)
ACE_Service_Config::~ACE_Service_Config (void)
{
ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config");
-
- // We do not want ~ACE_TSS<> to delete this again (single-thread
- // builds)
- this->tss_.ts_object (0);
}
// ************************************************************