summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2005-01-25 12:45:55 +0000
committerBenoit Foucher <benoit@zeroc.com>2005-01-25 12:45:55 +0000
commit0a61378b7e528c860c598a85207f9c007af33c0d (patch)
tree01b0ad3518b6f595b3f737b500b6de4d2d54e6bd /cpp/src
parentFix (diff)
downloadice-0a61378b7e528c860c598a85207f9c007af33c0d.tar.bz2
ice-0a61378b7e528c860c598a85207f9c007af33c0d.tar.xz
ice-0a61378b7e528c860c598a85207f9c007af33c0d.zip
Fixed bug where the transceiver wasn't properly closed if the connection
couldn't be created.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/ConnectionI.cpp81
1 files changed, 49 insertions, 32 deletions
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index 743e6eaa00e..915e1b4be49 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -1402,56 +1402,73 @@ Ice::ConnectionI::ConnectionI(const InstancePtr& instance,
replyHdr[8] = replyMsg;
replyHdr[9] = 0;
- if(_adapter)
+ ObjectAdapterI* adapterImpl = _adapter ? dynamic_cast<ObjectAdapterI*>(_adapter.get()) : 0;
+ if(adapterImpl)
{
- _servantManager = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getServantManager();
+ _servantManager = adapterImpl->getServantManager();
}
- if(!_instance->threadPerConnection())
+ __setNoDelete(true);
+ try
{
- //
- // Only set _threadPool if we really need it, i.e., if we are
- // not in thread per connection mode. Thread pools have lazy
- // initialization in Instance, and we don't want them to be
- // created if they are not needed.
- //
- if(_adapter)
+ if(!_instance->threadPerConnection())
{
- const_cast<ThreadPoolPtr&>(_threadPool) = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool();
+ //
+ // Only set _threadPool if we really need it, i.e., if we are
+ // not in thread per connection mode. Thread pools have lazy
+ // initialization in Instance, and we don't want them to be
+ // created if they are not needed.
+ //
+ if(adapterImpl)
+ {
+ const_cast<ThreadPoolPtr&>(_threadPool) = adapterImpl->getThreadPool();
+ }
+ else
+ {
+ const_cast<ThreadPoolPtr&>(_threadPool) = _instance->clientThreadPool();
+ }
}
else
{
- const_cast<ThreadPoolPtr&>(_threadPool) = _instance->clientThreadPool();
- }
- }
- else
- {
- //
- // If we are in thread per connection mode, create the thread
- // for this connection.
- //
- __setNoDelete(true);
- try
- {
+ //
+ // If we are in thread per connection mode, create the thread
+ // for this connection.
+ //
_threadPerConnection = new ThreadPerConnection(this);
_threadPerConnection->start(_instance->threadPerConnectionStackSize());
}
- catch(const IceUtil::Exception& ex)
+ }
+ catch(const IceUtil::Exception& ex)
+ {
{
+ Error out(_logger);
+ if(_instance->threadPerConnection())
{
- Error out(_logger);
out << "cannot create thread for connection:\n" << ex;
}
-
- _state = StateClosed;
- _transceiver = 0;
- _threadPerConnection = 0;
-
- __setNoDelete(false);
- throw;
+ else
+ {
+ out << "cannot create thread pool for connection:\n" << ex;
+ }
}
+
+ _state = StateClosed;
+
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+ _transceiver = 0;
+ _threadPerConnection = 0;
+
__setNoDelete(false);
+ throw;
}
+ __setNoDelete(false);
}
Ice::ConnectionI::~ConnectionI()