Fixed a race condition in client proxy thread.

Added some gdk mutex calls in timeout/idle callbacks.


git-svn-id: http://yate.null.ro/svn/yate/trunk@554 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2005-10-31 18:22:07 +00:00
parent 9b0a4adf0c
commit 7ecb56c22d
3 changed files with 14 additions and 3 deletions

View File

@ -112,8 +112,13 @@ public:
static gboolean gtkIdleCb(gpointer dat)
{
if (dat)
if (dat) {
// idle and timeout callbacks are called from glib directly
// so gtk/gdk thread safety is not assured by default
gdk_threads_enter();
static_cast<GTKClient*>(dat)->idleActions();
gdk_threads_leave();
}
return true;
}

View File

@ -255,8 +255,8 @@ bool ClientThreadProxy::execute()
Debugger debug(DebugAll,"ClientThreadProxy::execute()"," %d in %p [%p]",
m_func,Thread::current(),this);
s_proxyMutex.lock();
s_busy = true;
s_proxy = this;
s_busy = true;
while (s_busy)
Thread::yield();
s_proxyMutex.unlock();
@ -931,6 +931,8 @@ void Client::enableAction(const ClientChannel* chan, const String& action)
void Client::idleActions()
{
if (!s_busy)
return;
ClientThreadProxy* tmp = s_proxy;
s_proxy = 0;
if (tmp)

View File

@ -47,8 +47,12 @@ static Mutex s_mutex;
static gboolean mozIntervalCb(gpointer dat)
{
if (dat)
if (dat) {
// interval callback called from glib directly
gdk_threads_enter();
static_cast<MozWidget*>(dat)->setTextAsync();
gdk_threads_leave();
}
return false;
}