From 6891895cb3264e8cc25247fef2fb9f7adc1c3e66 Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 4 Nov 2014 22:34:30 +1100 Subject: [PATCH] ckdb - use new shutdown for the confirmer --- src/ckdb.c | 54 ++++++++++++++++++++++++++++-------------------------- src/ckdb.h | 2 +- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 794b9270..e52a8a32 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -3473,6 +3473,8 @@ int main(int argc, char **argv) if (confirm_sharesummary) { // TODO: add a system lock to stop running 2 at once? confirm_summaries(); + everyone_die = true; + socketer_release = summariser_release = listener_release = true; } else { ckp.main.sockname = strdup("listener"); write_namepid(&ckp.main); @@ -3488,38 +3490,38 @@ int main(int argc, char **argv) /* Shutdown from here if the listener is sent a shutdown message */ join_pthread(ckp.pth_listener); + } - time_t start, trigger, now; - char *msg = NULL; + time_t start, trigger, curr; + char *msg = NULL; - trigger = start = time(NULL); - while (!socketer_release || !summariser_release || - !logger_release || !listener_release) { - msg = NULL; - now = time(NULL); - if (now - start > 4) { - if (now - trigger > 4) { - msg = "Shutdown initial delay"; - } else if (now - trigger > 2) { - msg = "Shutdown delay"; - } - } - if (msg) { - trigger = now; - printf("%s %ds due to%s%s%s%s\n", - msg, (int)(now - start), - socketer_release ? EMPTY : " socketer", - summariser_release ? EMPTY : " summariser", - logger_release ? EMPTY : " logger", - listener_release ? EMPTY : " listener"); - fflush(stdout); + trigger = start = time(NULL); + while (!socketer_release || !summariser_release || + !logger_release || !listener_release) { + msg = NULL; + curr = time(NULL); + if (curr - start > 4) { + if (curr - trigger > 4) { + msg = "Shutdown initial delay"; + } else if (curr - trigger > 2) { + msg = "Shutdown delay"; } - sleep(1); } - - dealloc_storage(); + if (msg) { + trigger = curr; + printf("%s %ds due to%s%s%s%s\n", + msg, (int)(curr - start), + socketer_release ? EMPTY : " socketer", + summariser_release ? EMPTY : " summariser", + logger_release ? EMPTY : " logger", + listener_release ? EMPTY : " listener"); + fflush(stdout); + } + sleep(1); } + dealloc_storage(); + clean_up(&ckp); return 0; diff --git a/src/ckdb.h b/src/ckdb.h index a4fdb239..897cd705 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.2" -#define CKDB_VERSION DB_VERSION"-0.593" +#define CKDB_VERSION DB_VERSION"-0.594" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__