From: Pekka Riikonen Date: Mon, 2 Jul 2007 18:01:30 +0000 (+0000) Subject: Change silc_cond_signal calls to silc_cond_broadcast. We have X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=4cd7c9f48a8815462002a3af47733862584cd1ff Change silc_cond_signal calls to silc_cond_broadcast. We have to reach multiple threads. --- diff --git a/lib/silcutil/silcthread.c b/lib/silcutil/silcthread.c index 0c6d6421..80564234 100644 --- a/lib/silcutil/silcthread.c +++ b/lib/silcutil/silcthread.c @@ -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); } diff --git a/lib/silcutil/tests/test_silcstack.c b/lib/silcutil/tests/test_silcstack.c index c2416c6d..e4f87064 100644 --- a/lib/silcutil/tests/test_silcstack.c +++ b/lib/silcutil/tests/test_silcstack.c @@ -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);