Skip to content
This repository
Browse code

Re-evaluate predicate after returning from condition wait

This is needed because pthread_cond_wait() can wake up for no apparent reason
(i.e. not due to a call to pthread_cond_signal() or
pthread_cond_broadcast()). See [1]. Should hopefully solve #18.

[1] - http://lists.freebsd.org/pipermail/freebsd-hackers/2011-February/034573.html
  • Loading branch information...
commit 2f25b63d4393620d5b3cf1cc9505b34055588dee 1 parent 0a77275
Erik Johansson erijo authored

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. +5 2 licq/src/plugin/pluginthread.cpp
7 licq/src/plugin/pluginthread.cpp
... ... @@ -1,6 +1,6 @@
1 1 /*
2 2 * This file is part of Licq, an instant messaging client for UNIX.
3   - * Copyright (C) 2010 Licq developers
  3 + * Copyright (C) 2010-2011 Licq developers
4 4 *
5 5 * Licq is free software; you can redistribute it and/or modify
6 6 * it under the terms of the GNU General Public License as published by
@@ -86,7 +86,10 @@ static void* pluginThreadEntry(void* arg)
86 86
87 87 while (data.myState == PluginThread::Data::STATE_WAITING)
88 88 {
89   - data.myCondition.wait(data.myMutex);
  89 + do
  90 + {
  91 + data.myCondition.wait(data.myMutex);
  92 + } while (data.myState == PluginThread::Data::STATE_WAITING);
90 93
91 94 switch (data.myState)
92 95 {

0 comments on commit 2f25b63

Please sign in to comment.
Something went wrong with that request. Please try again.