Fix lock handling bug in commit aac980de43a0466b968a56607664f5ebbca6b751.
authorKen Raeburn <raeburn@raeburn.org>
Sun, 20 May 2012 09:22:01 +0000 (05:22 -0400)
committerKen Raeburn <raeburn@raeburn.org>
Mon, 21 May 2012 03:12:00 +0000 (23:12 -0400)
* libguile/weak-set.c (resize_set): When releasing a lock temporarily to do
  an allocation, re-lock it afterwards, instead of unlocking again.
* libguile/weak-table.c (resize_table): Likewise.

libguile/weak-set.c
libguile/weak-table.c

index bdabedf..33402b5 100644 (file)
@@ -362,7 +362,7 @@ resize_set (scm_t_weak_set *set)
          run anything, so drop our lock to avoid deadlocks.  */
       new_entries = scm_gc_malloc_pointerless (new_size * sizeof(scm_t_weak_entry),
                                                "weak set");
-      scm_i_pthread_mutex_unlock (&set->lock);
+      scm_i_pthread_mutex_lock (&set->lock);
     }
   while (!is_acceptable_size_index (set, new_size_index));
 
index 6a3fecd..be73e1b 100644 (file)
@@ -484,7 +484,7 @@ resize_table (scm_t_weak_table *table)
       /* Allocating memory might cause finalizers to run, which could
          run anything, so drop our lock to avoid deadlocks.  */
       new_entries = allocate_entries (new_size, table->kind);
-      scm_i_pthread_mutex_unlock (&table->lock);
+      scm_i_pthread_mutex_lock (&table->lock);
     }
   while (!is_acceptable_size_index (table, new_size_index));