From 6ea96719abd8c3fdff143a9bf10e474923bac962 Mon Sep 17 00:00:00 2001 From: crs Date: Wed, 10 Nov 2004 21:00:30 +0000 Subject: [PATCH] Made condition variable data volatile. This will hopefully fix an strange deadlock seen on OSX. The CSocketMultiplexer deadlocks with two threads, one waiting for m_polling to become false and the other waiting for m_pollable to become true. The weird part is that they're both false so the first thread should proceed. It either didn't receive the broadcast when m_polling went to false or it's not really checking the actual value of that flag. I can't see how the former is possible and this change fixes the latter. --- lib/mt/CCondVar.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/mt/CCondVar.h b/lib/mt/CCondVar.h index 78fbfe90..a04102c4 100644 --- a/lib/mt/CCondVar.h +++ b/lib/mt/CCondVar.h @@ -160,12 +160,12 @@ public: Get the variable's value. The condition variable should be locked before calling this method. */ - operator const T&() const; + operator const volatile T&() const; //@} private: - T m_data; + volatile T m_data; }; template @@ -199,8 +199,7 @@ CCondVar::~CCondVar() template inline CCondVar& -CCondVar::operator=( - const CCondVar& cv) +CCondVar::operator=(const CCondVar& cv) { m_data = cv.m_data; return *this; @@ -209,8 +208,7 @@ CCondVar::operator=( template inline CCondVar& -CCondVar::operator=( - const T& data) +CCondVar::operator=(const T& data) { m_data = data; return *this; @@ -218,7 +216,7 @@ CCondVar::operator=( template inline -CCondVar::operator const T&() const +CCondVar::operator const volatile T&() const { return m_data; }