summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-02-25 20:06:08 +0000
committerMarc Laukien <marc@zeroc.com>2004-02-25 20:06:08 +0000
commitab88b13dc35754ebf019785c9872fd8a8a119ab2 (patch)
tree9e394cecdb7eee99fd604fe11fd8e3e5121f95e6 /cpp/src
parentthread promotion fix (diff)
downloadice-ab88b13dc35754ebf019785c9872fd8a8a119ab2.tar.bz2
ice-ab88b13dc35754ebf019785c9872fd8a8a119ab2.tar.xz
ice-ab88b13dc35754ebf019785c9872fd8a8a119ab2.zip
thread promotion fix
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Connection.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 2f07fb5a054..93615e6e4ba 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -1152,12 +1152,6 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
return;
}
- //
- // For all other messages, we can promote a follower right away,
- // without setting the state first, or holding the mutex lock.
- //
- threadPool->promoteFollower();
-
OutgoingAsyncPtr outAsync;
Int invoke = 0;
Int requestId = 0;
@@ -1169,6 +1163,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
if(_state == StateClosed)
{
+ threadPool->promoteFollower();
return;
}
@@ -1327,11 +1322,25 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
catch(const LocalException& ex)
{
setState(StateClosed, ex);
+ threadPool->promoteFollower();
return;
}
}
//
+ // For all messages other than close connection (see comment
+ // above), we can promote a follower thread without holding the
+ // mutex lock. However, this must be done after requests have been
+ // removed from the request maps (due to reply messages, see code
+ // above). Otherwise there is a race condition with a close
+ // connection message that is received after reply messages. The
+ // close connection message might be processed before the reply
+ // messages are procsessed, meaning that requests would see a
+ // close connection instead of the response they already received.
+ //
+ threadPool->promoteFollower();
+
+ //
// Asynchronous replies must be handled outside the thread
// synchronization, so that nested calls are possible.
//