Mercurial > hg > freeDiameter
changeset 1328:81af4f5a517a
Improve shutdown.
Should generate less messages that can not get sent out.
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Mon, 27 Nov 2017 15:22:42 +0100 |
parents | 82b386714795 |
children | 175f2eb883a0 |
files | libfdcore/routing_dispatch.c |
diffstat | 1 files changed, 14 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/libfdcore/routing_dispatch.c Mon Nov 27 15:21:20 2017 +0100 +++ b/libfdcore/routing_dispatch.c Mon Nov 27 15:22:42 2017 +0100 @@ -1074,20 +1074,6 @@ do { struct msg * msg; - /* Test the current order */ - { - int must_stop; - CHECK_POSIX_DO( pthread_mutex_lock(&order_state_lock), { ASSERT(0); } ); /* we lock to flush the caches */ - must_stop = (order_val == STOP); - CHECK_POSIX_DO( pthread_mutex_unlock(&order_state_lock), { ASSERT(0); } ); - if (must_stop) - goto end; - - pthread_testcancel(); - } - - /* Ok, we are allowed to run */ - /* Get the next message from the queue */ { int ret; @@ -1097,9 +1083,21 @@ ts.tv_sec += 1; ret = fd_fifo_timedget ( queue, &msg, &ts ); - if (ret == ETIMEDOUT) - /* loop, check if the thread must stop now */ + if (ret == ETIMEDOUT) { + /* Test the current order */ + { + int must_stop; + CHECK_POSIX_DO( pthread_mutex_lock(&order_state_lock), { ASSERT(0); } ); /* we lock to flush the caches */ + must_stop = (order_val == STOP); + CHECK_POSIX_DO( pthread_mutex_unlock(&order_state_lock), { ASSERT(0); } ); + if (must_stop) + goto end; + + pthread_testcancel(); + } + /* Ok, we are allowed to continue */ continue; + } if (ret == EPIPE) /* The queue was destroyed, we are probably exiting */ goto end;