diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bb45de8..71b42f88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +### v. 0.7.3 + +**Fix**: (`fio`) fixes an issue where timer cleanup wasn't performed after `fio_stop` (or SIGINT/SIGTERM). No a "clean slate" will be provided if `fio_start` is called more then once. Note: this may **break previous behavior**, which should be considered undocumented and unexpected behavior. (this fax **may** be deferred to version 0.8.x, still undecided). Credit to @fbrausse for opening issue #72. + +**Fix**: (`fio`) fixes an issue where timer cleanup would be performed after the `AT_EXIT` state callbacks. Now the timer cleanup callbacks will be performed **before** the `AT_EXIT` callback (as they should). (See issue #72). + +**Fix**: (`fio`) fixes an issue where timer cleanup would be performed after the `AT_EXIT` state callbacks. Now the timer cleanup callbacks will be performed **before** the `AT_EXIT` callback (as they should). (See issue #72). + +**Fix**: (`fio`) fixes signal handler (re)establishment test to prevent recursive signal calling. + ### v. 0.7.2 **Fix**: (`fio_tls`) fixes a memory leak in the trusted certificate chain. Credit to @fbrausse for opening PR #71. diff --git a/lib/facil/fio.c b/lib/facil/fio.c index 9095a6c2..8b2862cd 100644 --- a/lib/facil/fio.c +++ b/lib/facil/fio.c @@ -1178,12 +1178,13 @@ static inline void fio_mark_time(void) { /** Calculates the due time for a task, given it's interval */ static struct timespec fio_timer_calc_due(size_t interval) { struct timespec now = fio_last_tick(); - if (interval > 1000) { - now.tv_sec += interval / 1000; - interval -= interval / 1000; + if (interval >= 1000) { + unsigned long long secs = interval / 1000; + now.tv_sec += secs; + interval -= secs * 1000; } now.tv_nsec += (interval * 1000000UL); - if (now.tv_nsec > 1000000000L) { + if (now.tv_nsec >= 1000000000L) { now.tv_nsec -= 1000000000L; now.tv_sec += 1; } @@ -1346,7 +1347,7 @@ Section Start Marker ***************************************************************************** */ volatile uint8_t fio_signal_children_flag = 0; - +volatile fio_lock_i fio_signal_set_flag = 0; /* store old signal handlers to propegate signal handling */ static struct sigaction fio_old_sig_chld; static struct sigaction fio_old_sig_pipe; @@ -1415,7 +1416,7 @@ static void sig_int_handler(int sig) { break; } /* propagate signale handling to previous existing handler (if any) */ - if (old->sa_handler != SIG_IGN && old->sa_handler != SIG_DFL) + if (old && old->sa_handler != SIG_IGN && old->sa_handler != SIG_DFL) old->sa_handler(sig); } @@ -1423,7 +1424,7 @@ static void sig_int_handler(int sig) { static void fio_signal_handler_setup(void) { /* setup signal handling */ struct sigaction act; - if (fio_old_sig_int.sa_handler) + if (fio_trylock(&fio_signal_set_flag)) return; memset(&act, 0, sizeof(act)); @@ -1457,8 +1458,9 @@ static void fio_signal_handler_setup(void) { void fio_signal_handler_reset(void) { struct sigaction old; - if (!fio_old_sig_int.sa_handler) + if (fio_signal_set_flag) return; + fio_unlock(&fio_signal_set_flag); memset(&old, 0, sizeof(old)); sigaction(SIGINT, &fio_old_sig_int, &old); sigaction(SIGTERM, &fio_old_sig_term, &old); @@ -3533,11 +3535,12 @@ static void __attribute__((destructor)) fio_lib_destroy(void) { fio_data->active = 0; fio_on_fork(); fio_defer_perform(); + fio_timer_clear_all(); + fio_defer_perform(); fio_state_callback_force(FIO_CALL_AT_EXIT); fio_state_callback_clear_all(); fio_defer_perform(); fio_poll_close(); - fio_timer_clear_all(); fio_free(fio_data); /* memory library destruction must be last */ fio_mem_destroy(); @@ -3811,8 +3814,7 @@ static void fio_worker_cleanup(void) { fio_force_close(fd2uuid(i)); } } - fio_defer_perform(); - fio_state_callback_force(FIO_CALL_ON_FINISH); + fio_timer_clear_all(); fio_defer_perform(); if (!fio_data->is_worker) { kill(0, SIGINT); @@ -3820,6 +3822,8 @@ static void fio_worker_cleanup(void) { ; } fio_defer_perform(); + fio_state_callback_force(FIO_CALL_ON_FINISH); + fio_defer_perform(); fio_signal_handler_reset(); if (fio_data->parent == getpid()) { FIO_LOG_INFO(" --- Shutdown Complete ---\n"); diff --git a/lib/facil/fio.h b/lib/facil/fio.h index cb8de480..cd23e14b 100644 --- a/lib/facil/fio.h +++ b/lib/facil/fio.h @@ -109,7 +109,7 @@ Version and helper macros #define FIO_VERSION_MAJOR 0 #define FIO_VERSION_MINOR 7 -#define FIO_VERSION_PATCH 2 +#define FIO_VERSION_PATCH 3 #define FIO_VERSION_BETA 0 /* Automatically convert version data to a string constant - ignore these two */