Skip to content
Commit 99f0eaa4 authored by Allison Karlitskaya's avatar Allison Karlitskaya
Browse files

Fix bug in g_static_rec_mutex_unlock_full()

pthreads doesn't implement the _lock_full() and _unlock_full() calls on
recursive mutexes so we don't have it on GRecMutex either.  Now that
we're using GRecMutex to implement GStaticRecMutex, we have to fake it
by keeping an internal counter of the number of locks and calling
g_rec_mutex_unlock() the appropriate number of times.

The code to do this looked like:

  depth = mutex->depth;
  while (mutex->depth--)
    g_rec_mutex_unlock (rm);
  return depth;

which unfortunately did one last decrement after mutex->depth was
already zero (leaving it equal to -1).

When locked the next time, the count would then increase from -1 to 0
and then the next _unlock_full() call would not do any calls to
g_rec_mutex_unlock(), leading to a deadlock.

https://bugzilla.gnome.org/show_bug.cgi?id=661914
parent aba0f0c3
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment