summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ConnectionI.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2014-09-22 10:54:30 -0230
committerDwayne Boone <dwayne@zeroc.com>2014-09-22 10:54:30 -0230
commit2adece994af052395e0372958b63a9d95ea1b20b (patch)
treefd159f56092a67a799511f6979401479d6dba0f1 /cpp/src/Ice/ConnectionI.cpp
parentICE-5660 Colloc-only object adapters (diff)
downloadice-2adece994af052395e0372958b63a9d95ea1b20b.tar.bz2
ice-2adece994af052395e0372958b63a9d95ea1b20b.tar.xz
ice-2adece994af052395e0372958b63a9d95ea1b20b.zip
ICE-5585 Connection::setCallback should always invoke the callback
Diffstat (limited to 'cpp/src/Ice/ConnectionI.cpp')
-rw-r--r--cpp/src/Ice/ConnectionI.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index 564e3ab88d7..c397e8d1b91 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -1177,12 +1177,37 @@ Ice::ConnectionI::flushAsyncBatchRequests(const BatchOutgoingAsyncPtr& outAsync)
void
Ice::ConnectionI::setCallback(const ConnectionCallbackPtr& callback)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(_state > StateClosing)
+ bool closed = false;
{
- return;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(_state > StateClosing)
+ {
+ closed = true;
+ return;
+ }
+ else
+ {
+ _callback = callback;
+ }
+ }
+
+ if(closed)
+ {
+ try
+ {
+ callback->closed(this);
+ }
+ catch(const std::exception& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "connection callback exception:\n" << ex << '\n' << _desc;
+ }
+ catch(...)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "connection callback exception:\nunknown c++ exception" << '\n' << _desc;
+ }
}
- _callback = callback;
}
void