summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2003-10-10 13:53:22 +0000
committerMarc Laukien <marc@zeroc.com>2003-10-10 13:53:22 +0000
commitc0bf25677da461c673e51cd7daabec8aceb8266a (patch)
tree9f900ced1a634ed28c193a3c3c184922c69f77e1 /cpp/src
parentfixed connection establishment deadlock (diff)
downloadice-c0bf25677da461c673e51cd7daabec8aceb8266a.tar.bz2
ice-c0bf25677da461c673e51cd7daabec8aceb8266a.tar.xz
ice-c0bf25677da461c673e51cd7daabec8aceb8266a.zip
fixed shutdown crash
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Connection.cpp60
-rw-r--r--cpp/src/Ice/Connection.h5
2 files changed, 36 insertions, 29 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 74554edddb8..cfb84752654 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -236,7 +236,6 @@ IceInternal::Connection::isValidated() const
{
// See _queryMutex comment in header file.
IceUtil::Mutex::Lock sync(_queryMutex);
-
return _state > StateNotValidated;
}
@@ -245,7 +244,6 @@ IceInternal::Connection::isDestroyed() const
{
// See _queryMutex comment in header file.
IceUtil::Mutex::Lock sync(_queryMutex);
-
return _state >= StateClosing;
}
@@ -254,13 +252,7 @@ IceInternal::Connection::isFinished() const
{
// See _queryMutex comment in header file.
IceUtil::Mutex::Lock sync(_queryMutex);
-
- //
- // If _transceiver is 0, then _dispatchCount must also be 0;
- //
- assert(!(_transceiver == 0 && _dispatchCount != 0));
-
- return _transceiver == 0;
+ return _transceiver == 0 && _dispatchCount == 0;
}
void
@@ -771,17 +763,22 @@ IceInternal::Connection::sendResponse(BasicStream* os, Byte compressFlag)
try
{
- if(_state == StateClosed)
{
- assert(_dispatchCount == 0);
- return;
+ // See _queryMutex comment in header file.
+ IceUtil::Mutex::Lock sync(_queryMutex);
+ --_dispatchCount;
}
-
- if(--_dispatchCount == 0)
+
+ if(_dispatchCount == 0)
{
notifyAll();
}
+ if(_state == StateClosed)
+ {
+ return;
+ }
+
bool compress;
if(os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes.
{
@@ -857,17 +854,22 @@ IceInternal::Connection::sendNoResponse()
try
{
- if(_state == StateClosed)
{
- assert(_dispatchCount == 0);
- return;
+ // See _queryMutex comment in header file.
+ IceUtil::Mutex::Lock sync(_queryMutex);
+ --_dispatchCount;
}
-
- if(--_dispatchCount == 0)
+
+ if(_dispatchCount == 0)
{
notifyAll();
}
+ if(_state == StateClosed)
+ {
+ return;
+ }
+
if(_state == StateClosing && _dispatchCount == 0)
{
initiateShutdown();
@@ -1059,7 +1061,11 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
traceRequest("received request", stream, _logger, _traceLevels);
stream.read(requestId);
invoke = 1;
- ++_dispatchCount;
+ {
+ // See _queryMutex comment in header file.
+ IceUtil::Mutex::Lock sync(_queryMutex);
+ ++_dispatchCount;
+ }
}
break;
}
@@ -1080,7 +1086,11 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
{
throw NegativeSizeException(__FILE__, __LINE__);
}
- _dispatchCount += invoke;
+ {
+ // See _queryMutex comment in header file.
+ IceUtil::Mutex::Lock sync(_queryMutex);
+ _dispatchCount += invoke;
+ }
}
break;
}
@@ -1406,6 +1416,8 @@ IceInternal::Connection::Connection(const InstancePtr& instance,
IceInternal::Connection::~Connection()
{
+ // See _queryMutex comment in header file.
+ IceUtil::Mutex::Lock sync(_queryMutex);
assert(_state == StateClosed);
assert(!_transceiver);
assert(_dispatchCount == 0);
@@ -1527,12 +1539,6 @@ IceInternal::Connection::setState(State state)
case StateClosed:
{
//
- // If we do a hard close, all outstanding requests are
- // disregarded.
- //
- _dispatchCount = 0;
-
- //
// If we change from not validated, we can close right
// away. Otherwise we first must make sure that we are
// registered, then we unregister, and let finished() do
diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h
index 2198fafbb83..3868ad2d9ad 100644
--- a/cpp/src/Ice/Connection.h
+++ b/cpp/src/Ice/Connection.h
@@ -166,8 +166,9 @@ private:
BasicStream _batchStream;
int _batchRequestNum;
- int _dispatchCount; // The number of requests currently being dispatched.
- int _proxyCount; // The number of proxies using this connection.
+ int _dispatchCount;
+
+ int _proxyCount;
State _state;