summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ConnectRequestHandler.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2014-09-26 18:39:28 +0200
committerBenoit Foucher <benoit@zeroc.com>2014-09-26 18:39:28 +0200
commitaa3c4ebfa279188cf689c6ef2318ed573c4fec7b (patch)
treec7c1c9b7b6ce2daee3cd9b5507a49d3520fd1d06 /cpp/src/Ice/ConnectRequestHandler.cpp
parentSlightly improved fix for ICE-3692 (diff)
downloadice-aa3c4ebfa279188cf689c6ef2318ed573c4fec7b.tar.bz2
ice-aa3c4ebfa279188cf689c6ef2318ed573c4fec7b.tar.xz
ice-aa3c4ebfa279188cf689c6ef2318ed573c4fec7b.zip
Fixed deadlock in connection binding code (ICE-5693)
Diffstat (limited to 'cpp/src/Ice/ConnectRequestHandler.cpp')
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp
index 874858e1c7e..7a6b495a13f 100644
--- a/cpp/src/Ice/ConnectRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectRequestHandler.cpp
@@ -91,19 +91,36 @@ ConnectRequestHandler::~ConnectRequestHandler()
RequestHandlerPtr
ConnectRequestHandler::connect()
{
+ Ice::ObjectPrx proxy = _proxy;
+
_reference->getConnection(this);
- Lock sync(*this);
- if(initialized())
+ try
{
- assert(_connection);
- return new ConnectionRequestHandler(_reference, _connection, _compress);
+ Lock sync(*this);
+ if(!initialized())
+ {
+ _updateRequestHandler = true; // The proxy request handler will be updated when the connection is set.
+ return this;
+ }
}
- else
+ catch(const Ice::LocalException&)
{
- _updateRequestHandler = true; // The proxy request handler will be updated when the connection is set.
- return this;
+ proxy->__setRequestHandler(this, 0);
+ throw;
}
+
+ assert(_connection);
+
+ RequestHandlerPtr handler = new ConnectionRequestHandler(_reference, _connection, _compress);
+ proxy->__setRequestHandler(this, handler);
+ return handler;
+}
+
+RequestHandlerPtr
+ConnectRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler)
+{
+ return previousHandler.get() == this ? newHandler : this;
}
void
@@ -335,8 +352,6 @@ ConnectRequestHandler::setConnection(const Ice::ConnectionIPtr& connection, bool
{
Lock sync(*this);
assert(!_exception.get() && !_connection);
- assert(_updateRequestHandler || _requests.empty());
-
_connection = connection;
_compress = compress;
}
@@ -362,8 +377,6 @@ ConnectRequestHandler::setException(const Ice::LocalException& ex)
{
Lock sync(*this);
assert(!_initialized && !_exception.get());
- assert(_updateRequestHandler || _requests.empty());
-
_exception.reset(ex.ice_clone());
_proxy = 0; // Break cyclic reference count.