summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-04-18 14:45:21 +0000
committerMarc Laukien <marc@zeroc.com>2004-04-18 14:45:21 +0000
commitf1f9d4683dc42533ea66c14e59a96e8fc0c7b651 (patch)
treee94c0e1c8b7c7a24f5dc318f0523ea501afa7205 /cpp/src
parentassertions are now correctly caught (diff)
downloadice-f1f9d4683dc42533ea66c14e59a96e8fc0c7b651.tar.bz2
ice-f1f9d4683dc42533ea66c14e59a96e8fc0c7b651.tar.xz
ice-f1f9d4683dc42533ea66c14e59a96e8fc0c7b651.zip
fixes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Connection.cpp20
-rw-r--r--cpp/src/Ice/Incoming.cpp50
-rw-r--r--cpp/src/Ice/IncomingAsync.cpp16
3 files changed, 75 insertions, 11 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 4630e41787c..bb187af20fb 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -1303,7 +1303,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
//
try
{
- while(invoke-- > 0)
+ while(invoke > 0)
{
//
// Prepare the invocation.
@@ -1319,7 +1319,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
//
if(response)
{
- assert(invoke == 0); // No further invocations if a response is expected.
+ assert(invoke == 1); // No further invocations if a response is expected.
os->writeBlob(_replyHdr);
//
@@ -1333,7 +1333,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
//
// If there are more invocations, we need the stream back.
//
- if(invoke > 0)
+ if(--invoke > 0)
{
stream.swap(*is);
}
@@ -1343,6 +1343,20 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
setState(StateClosed, ex);
+
+ //
+ // If invoke() above raised an exception, and therefore
+ // neither sendResponse() nor sendNoResponse() has been
+ // called, then we must decrement _dispatchCount here.
+ //
+ assert(invoke > 0);
+ assert(_dispatchCount > 0);
+ _dispatchCount -= invoke;
+ assert(_dispatchCount >= 0);
+ if(_dispatchCount == 0)
+ {
+ notifyAll();
+ }
}
}
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index c4d1aabe532..acba0edf3b0 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -200,6 +200,8 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
}
catch(RequestFailedException& ex)
{
+ _is.endReadEncaps();
+
if(ex.id.name.empty())
{
ex.id = _current.id;
@@ -260,12 +262,17 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_os.write(ex.operation);
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
catch(const LocalException& ex)
{
+ _is.endReadEncaps();
+
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
__warning(ex);
@@ -281,12 +288,17 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_os.write(str.str());
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
catch(const UserException& ex)
{
+ _is.endReadEncaps();
+
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
__warning(ex);
@@ -302,12 +314,17 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_os.write(str.str());
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
catch(const Exception& ex)
{
+ _is.endReadEncaps();
+
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
__warning(ex);
@@ -323,12 +340,17 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_os.write(str.str());
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
catch(const std::exception& ex)
{
+ _is.endReadEncaps();
+
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
__warning(string("std::exception: ") + ex.what());
@@ -344,12 +366,17 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_os.write(str.str());
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
catch(...)
{
+ _is.endReadEncaps();
+
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
__warning("unknown c++ exception");
@@ -364,8 +391,11 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_os.write(reason);
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
return;
}
@@ -375,6 +405,8 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
// the caller of this operation.
//
+ _is.endReadEncaps();
+
//
// DispatchAsync is "pseudo dispatch status", used internally only
// to indicate async dispatch.
@@ -386,7 +418,6 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
// do *not* call __finishInvoke(), because the call is not
// finished yet.
//
- _is.endReadEncaps();
return;
}
@@ -427,6 +458,9 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
}
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
- _is.endReadEncaps();
}
diff --git a/cpp/src/Ice/IncomingAsync.cpp b/cpp/src/Ice/IncomingAsync.cpp
index deb7e81fd6b..5288047d08c 100644
--- a/cpp/src/Ice/IncomingAsync.cpp
+++ b/cpp/src/Ice/IncomingAsync.cpp
@@ -59,6 +59,10 @@ IceInternal::IncomingAsync::__response(bool ok)
}
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
}
@@ -186,6 +190,10 @@ IceInternal::IncomingAsync::__exception(const Exception& exc)
}
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
}
@@ -210,6 +218,10 @@ IceInternal::IncomingAsync::__exception(const std::exception& ex)
_os.write(str.str());
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
}
@@ -233,6 +245,10 @@ IceInternal::IncomingAsync::__exception()
_os.write(reason);
}
+ //
+ // Must be called last, so that if an exception is raised,
+ // this function is definitely *not* called.
+ //
__finishInvoke();
}