Change silc_cond_signal calls to silc_cond_broadcast. We have
authorPekka Riikonen <priikone@silcnet.org>
Mon, 2 Jul 2007 18:01:30 +0000 (18:01 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 2 Jul 2007 18:01:30 +0000 (18:01 +0000)
to reach multiple threads.

lib/silcutil/silcthread.c
lib/silcutil/tests/test_silcstack.c

index 0c6d6421a4b810e39cde8d72d6f91cb89dedaf53..805642344dbf1aeb762f62131d20ba1448972523 100644 (file)
@@ -117,7 +117,7 @@ static void *silc_thread_pool_run_thread(void *context)
 
       /* If we are last thread, signal the waiting destructor. */
       if (silc_list_count(tp->threads) == 0)
-       silc_cond_signal(pool_signal);
+       silc_cond_broadcast(pool_signal);
 
       /* Release pool reference.  Releases lock also. */
       silc_thread_pool_unref(tp);
@@ -270,7 +270,7 @@ void silc_thread_pool_free(SilcThreadPool tp, SilcBool wait_unfinished)
   silc_list_start(tp->threads);
   while ((t = silc_list_get(tp->threads)))
     t->stop = TRUE;
-  silc_cond_signal(tp->pool_signal);
+  silc_cond_broadcast(tp->pool_signal);
 
   if (wait_unfinished) {
     SILC_LOG_DEBUG(("Wait threads to finish"));
@@ -357,7 +357,7 @@ SilcBool silc_thread_pool_run(SilcThreadPool tp,
   silc_list_del(tp->free_threads, t);
 
   /* Signal threads */
-  silc_cond_signal(tp->pool_signal);
+  silc_cond_broadcast(tp->pool_signal);
 
   silc_mutex_unlock(tp->lock);
   return TRUE;
@@ -411,6 +411,7 @@ void silc_thread_pool_purge(SilcThreadPool tp)
   silc_mutex_lock(tp->lock);
 
   if (silc_list_count(tp->free_threads) <= tp->min_threads) {
+    SILC_LOG_DEBUG(("No threads to purge"));
     silc_mutex_unlock(tp->lock);
     return;
   }
@@ -433,7 +434,7 @@ void silc_thread_pool_purge(SilcThreadPool tp)
   }
 
   /* Signal threads to stop */
-  silc_cond_signal(tp->pool_signal);
+  silc_cond_broadcast(tp->pool_signal);
 
   silc_mutex_unlock(tp->lock);
 }
index c2416c6db3ebccd66b3aea047042418c4143ef15..e4f87064087ff7fb7cb4b9275a9c8e1957189eb9 100644 (file)
@@ -93,6 +93,27 @@ int main(int argc, char **argv)
   SILC_LOG_DEBUG(("Popping"));
   silc_stack_stats(stack);
 
+  SILC_LOG_DEBUG(("Current alignment: %d", silc_stack_get_alignment(stack)));
+  SILC_LOG_DEBUG(("Set alignemtn to 16"));
+  silc_stack_set_alignment(stack, 16);
+  SILC_LOG_DEBUG(("Current alignment: %d", silc_stack_get_alignment(stack)));
+  SILC_LOG_DEBUG(("Allocate 1 byte"));
+  ptr = silc_smalloc(stack, 1);
+  SILC_LOG_DEBUG(("Allocate 1 byte, check alignment"));
+  ptr2 = silc_smalloc(stack, 1);
+  if (ptr2 - ptr < 16) {
+    SILC_LOG_DEBUG(("Bad alignment"));
+    goto err;
+  }
+  SILC_LOG_DEBUG(("Alignment (ptr, ptr2) is %d", ptr2 - ptr));
+  SILC_LOG_DEBUG(("Allocate 1 byte, check alignment"));
+  ptr2 = silc_smalloc(stack, 1);
+  if (ptr2 - ptr < 32) {
+    SILC_LOG_DEBUG(("Bad alignment"));
+    goto err;
+  }
+  SILC_LOG_DEBUG(("Alignment (ptr, ptr2) is %d", ptr2 - ptr));
+
   SILC_LOG_DEBUG(("Freeing the stack"));
   silc_stack_free(stack);