summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2003-01-15 17:54:24 +0000
committerMarc Laukien <marc@zeroc.com>2003-01-15 17:54:24 +0000
commit18c4fbd25a501d244f281ba0c760472229b3b250 (patch)
tree52c1e8ff33c2d05e48fbd6171ed092608d9ce82a /cpp/src
parentfixed inc/decProxyCount & async requests (diff)
downloadice-18c4fbd25a501d244f281ba0c760472229b3b250.tar.bz2
ice-18c4fbd25a501d244f281ba0c760472229b3b250.tar.xz
ice-18c4fbd25a501d244f281ba0c760472229b3b250.zip
fixed inc/decProxyCount & async requests
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Connection.cpp22
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp15
2 files changed, 21 insertions, 16 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index fd740488944..d35c4177995 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -201,10 +201,16 @@ IceInternal::Connection::decProxyCount()
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
assert(_proxyCount > 0);
--_proxyCount;
- if(_proxyCount == 0 && !_adapter)
+
+ //
+ // We close the connection if
+ // - no proxy uses this connection anymore; and
+ // - there are not outstanding asynchronous requests; and
+ // - this is an outgoing connection only.
+ //
+ if(_proxyCount == 0 && _asyncRequests.empty() && !_adapter)
{
assert(_requests.empty());
- assert(_asyncRequests.empty());
setState(StateClosing, CloseConnectionException(__FILE__, __LINE__));
}
}
@@ -926,6 +932,18 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
{
_asyncRequests.erase(q);
}
+
+ //
+ // We close the connection if
+ // - no proxy uses this connection anymore; and
+ // - there are not outstanding asynchronous requests; and
+ // - this is an outgoing connection only.
+ //
+ if(_proxyCount == 0 && _asyncRequests.empty() && !_adapter)
+ {
+ assert(_requests.empty());
+ setState(StateClosing, CloseConnectionException(__FILE__, __LINE__));
+ }
}
break;
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index bc7727cd933..dca96e8346e 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -80,16 +80,7 @@ IceInternal::OutgoingAsync::__setup(const ConnectionPtr& connection, const Refer
void
IceInternal::OutgoingAsync::__invoke()
{
- _connection->incProxyCount();
- try
- {
- _connection->sendAsyncRequest(this, _compress);
- }
- catch(...)
- {
- _connection->decProxyCount();
- throw;
- }
+ _connection->sendAsyncRequest(this, _compress);
}
void
@@ -200,8 +191,6 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is)
{
warning();
}
-
- _connection->decProxyCount();
}
void
@@ -223,8 +212,6 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc)
{
warning();
}
-
- _connection->decProxyCount();
}
BasicStream*