summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ObjectAdapterI.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-08-24 22:01:20 +0000
committerMarc Laukien <marc@zeroc.com>2001-08-24 22:01:20 +0000
commit96f9a4887edb7d7778332e0eb12657b8ace3b42e (patch)
treef9476cd6037e8152def769f46ea7a67a7ab21b2b /cpp/src/Ice/ObjectAdapterI.cpp
parentmore activation stuff (diff)
downloadice-96f9a4887edb7d7778332e0eb12657b8ace3b42e.tar.bz2
ice-96f9a4887edb7d7778332e0eb12657b8ace3b42e.tar.xz
ice-96f9a4887edb7d7778332e0eb12657b8ace3b42e.zip
fixes
Diffstat (limited to 'cpp/src/Ice/ObjectAdapterI.cpp')
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp91
1 files changed, 49 insertions, 42 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 2a5ecee51ad..772c124962c 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -257,59 +257,66 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const string& n
{
string s(endpts);
transform(s.begin(), s.end(), s.begin(), tolower);
-
+
string::size_type beg = 0;
string::size_type end;
- while (true)
+ //
+ // Set the "no delete" flag to true, meaning that this object will
+ // not be deleted, even if the reference count drops to zero. This
+ // is needed because if the constructor of the CollectorFactory
+ // throws an exception, or if the CollectorFactories are destroyed
+ // with "deactivate" from within this constructor, all
+ // ObjectAdapterPtrs for this object will be destroyed, and thus
+ // this object would be deleted if the "no delete" flag is not
+ // set.
+ //
+ __setNoDelete(true);
+
+ try
{
- end = s.find(':', beg);
- if (end == string::npos)
- {
- end = s.length();
- }
-
- if (end == beg)
- {
- throw EndpointParseException(__FILE__, __LINE__);
- }
-
- string es = s.substr(beg, end - beg);
-
- // Don't store the endpoint in the adapter. The Collector
- // might change it, for example, to fill in the real port
- // number if a zero port number is given.
- EndpointPtr endp = Endpoint::endpointFromString(es);
- try
+ while (true)
{
- // Set the "no delete" flag to true, meaning that this
- // object will not be deleted, even if the reference count
- // drops to zero. This is needed because if the
- // constructor of the CollectorFactory throws an
- // exception, the only CollectorFactoryPtr reference for
- // this object will be the one that is temporarily
- // constructed for passing the "this" parameter below. And
- // then this temporary reference is destroyed, this object
- // would be deleted if we don't set the "no delete" flag.
- __setNoDelete(true);
+ end = s.find(':', beg);
+ if (end == string::npos)
+ {
+ end = s.length();
+ }
+
+ if (end == beg)
+ {
+ throw EndpointParseException(__FILE__, __LINE__);
+ }
+
+ string es = s.substr(beg, end - beg);
+
+ // Don't store the endpoint in the adapter. The Collector
+ // might change it, for example, to fill in the real port
+ // number if a zero port number is given.
+ EndpointPtr endp = Endpoint::endpointFromString(es);
_collectorFactories.push_back(new CollectorFactory(instance, this, endp));
- __setNoDelete(false);
- }
- catch(...)
- {
- __setNoDelete(false);
- throw;
+
+ if (end == s.length())
+ {
+ break;
+ }
+
+ beg = end + 1;
}
-
- if (end == s.length())
+ }
+ catch(...)
+ {
+ if (!_collectorFactories.empty())
{
- break;
+ deactivate();
}
-
- beg = end + 1;
+ __setNoDelete(false);
+ throw;
}
- if (!_collectorFactories.size())
+ __setNoDelete(false);
+
+ if (_collectorFactories.empty())
{
throw EndpointParseException(__FILE__, __LINE__);
}