summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2012-11-26 22:02:07 +0000
committerStephen D. Huston <shuston@apache.org>2012-11-26 22:02:07 +0000
commited5f5cceb580b70c8f87e1d630db4e76411334cb (patch)
tree89b86d060835ba548047f214954c043c9af0dc88 /qpid/cpp/src
parent1d8bc6e249ecb404b5344610204ec9424f099361 (diff)
downloadqpid-python-ed5f5cceb580b70c8f87e1d630db4e76411334cb.tar.gz
Prevent multiple threads from dispatching the condition handling at once. Fixes QPID-4424.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1413889 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp b/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp
index 7bbcd4de1b..3e2a5fb36c 100644
--- a/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp
+++ b/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp
@@ -52,13 +52,14 @@ private:
PollableCondition& parent;
boost::shared_ptr<sys::Poller> poller;
LONG isSet;
+ LONG isDispatching;
};
PollableConditionPrivate::PollableConditionPrivate(const sys::PollableCondition::Callback& cb,
sys::PollableCondition& parent,
const boost::shared_ptr<sys::Poller>& poller)
: IOHandle(INVALID_SOCKET, boost::bind(&PollableConditionPrivate::dispatch, this, _1)),
- cb(cb), parent(parent), poller(poller), isSet(0)
+ cb(cb), parent(parent), poller(poller), isSet(0), isDispatching(0)
{
}
@@ -77,7 +78,12 @@ void PollableConditionPrivate::poke()
void PollableConditionPrivate::dispatch(windows::AsynchIoResult *result)
{
delete result; // Poller::monitorHandle() allocates this
+ // If isDispatching is already set, just return. Else, enter.
+ if (::InterlockedCompareExchange(&isDispatching, 1, 0) == 1)
+ return;
cb(parent);
+ LONG oops = ::InterlockedDecrement(&isDispatching); // Result must be 0
+ assert(!oops);
if (isSet)
poke();
}