From c96ad497679d0418a3818def1e3f81d997a1226c Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Mon, 29 Jan 2001 16:32:26 +0000 Subject: [PATCH] Broadcast the condition, if there are waiting readers, as all might read 2001-01-29 Sebastian Wilhelmi * gthread.c: Broadcast the condition, if there are waiting readers, as all might read at the same time. Only signal the writer thread, if there are no more readers. * gthread/gthread-impl.c (g_mutex_free_errorcheck_impl): Add new check to errorcheck mutexes to abort, if a locked mutex is freed. --- ChangeLog | 6 ++++++ ChangeLog.pre-2-0 | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-12 | 6 ++++++ ChangeLog.pre-2-2 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ glib/gthread.c | 5 +++-- gthread.c | 5 +++-- gthread/ChangeLog | 5 +++++ gthread/gthread-impl.c | 5 +++++ 12 files changed, 64 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e7780a..a875da4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 9e7780a..a875da4 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9e7780a..a875da4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 9e7780a..a875da4 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 9e7780a..a875da4 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9e7780a..a875da4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9e7780a..a875da4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9e7780a..a875da4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread.c: Broadcast the condition, if there are waiting + readers, as all might read at the same time. Only signal the + writer thread, if there are no more readers. + 2001-01-25 Tor Lillqvist * makefile.mingw.in diff --git a/glib/gthread.c b/glib/gthread.c index 479ef9c..bbb18ac 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -517,7 +517,7 @@ static void inline g_static_rw_lock_signal (GStaticRWLock* lock) if (lock->want_to_write && lock->write_cond) g_cond_signal (lock->write_cond); else if (lock->read_cond) - g_cond_signal (lock->read_cond); + g_cond_broadcast (lock->read_cond); } void g_static_rw_lock_reader_lock (GStaticRWLock* lock) @@ -562,7 +562,8 @@ void g_static_rw_lock_reader_unlock (GStaticRWLock* lock) g_static_mutex_lock (&lock->mutex); lock->read_counter--; - g_static_rw_lock_signal (lock); + if (lock->read_counter == 0) + g_static_rw_lock_signal (lock); g_static_mutex_unlock (&lock->mutex); } diff --git a/gthread.c b/gthread.c index 479ef9c..bbb18ac 100644 --- a/gthread.c +++ b/gthread.c @@ -517,7 +517,7 @@ static void inline g_static_rw_lock_signal (GStaticRWLock* lock) if (lock->want_to_write && lock->write_cond) g_cond_signal (lock->write_cond); else if (lock->read_cond) - g_cond_signal (lock->read_cond); + g_cond_broadcast (lock->read_cond); } void g_static_rw_lock_reader_lock (GStaticRWLock* lock) @@ -562,7 +562,8 @@ void g_static_rw_lock_reader_unlock (GStaticRWLock* lock) g_static_mutex_lock (&lock->mutex); lock->read_counter--; - g_static_rw_lock_signal (lock); + if (lock->read_counter == 0) + g_static_rw_lock_signal (lock); g_static_mutex_unlock (&lock->mutex); } diff --git a/gthread/ChangeLog b/gthread/ChangeLog index 8288d80..551d37e 100644 --- a/gthread/ChangeLog +++ b/gthread/ChangeLog @@ -1,3 +1,8 @@ +2001-01-29 Sebastian Wilhelmi + + * gthread-impl.c (g_mutex_free_errorcheck_impl): Add new check to + errorcheck mutexes to abort, if a locked mutex is freed. + 2001-01-03 Sebastian Wilhelmi * gthread-solaris.c, gthread-posix.c: Made g_thread_min_stack_size diff --git a/gthread/gthread-impl.c b/gthread/gthread-impl.c index c8f01d0..56e2448 100644 --- a/gthread/gthread-impl.c +++ b/gthread/gthread-impl.c @@ -181,6 +181,11 @@ g_mutex_unlock_errorcheck_impl (GMutex *mutex, static void g_mutex_free_errorcheck_impl (GMutex *mutex) { + if (info && info->owner != NULL) + g_error ("Trying to free a locked mutex at '%s', " + "which was previously locked at '%s'", + location, info->location); + g_free (G_MUTEX_DEBUG_INFO (mutex)); g_thread_functions_for_glib_use_default.mutex_free (mutex); } -- 2.7.4