From 5d5e552a7ec6ef69459c97b0081aa775372a6290 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 14 Nov 2019 12:35:53 -0800 Subject: [PATCH] de-init hooks --- modules/database/src/ioc/misc/iocInit.c | 13 +++++++++++-- modules/libcom/src/iocsh/initHooks.h | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/database/src/ioc/misc/iocInit.c b/modules/database/src/ioc/misc/iocInit.c index dae83683b..4ce35ba18 100644 --- a/modules/database/src/ioc/misc/iocInit.c +++ b/modules/database/src/ioc/misc/iocInit.c @@ -710,20 +710,27 @@ int iocShutdown(void) { if (iocState == iocVoid) return 0; + initHookAnnounce(initHookAtShutdown); + iterateRecords(doCloseLinks, NULL); + initHookAnnounce(initHookAfterCloseLinks); if (iocBuildMode == buildIsolated) { /* stop and "join" threads */ scanStop(); + initHookAnnounce(initHookAfterStopScan); callbackStop(); - } - else + initHookAnnounce(initHookAfterStopCallback); + } else { dbStopServers(); + } dbCaShutdown(); /* must be before dbFreeRecord and dbChannelExit */ + initHookAnnounce(initHookAfterStopLinks); if (iocBuildMode == buildIsolated) { /* free resources */ + initHookAnnounce(initHookBeforeFree); scanCleanup(); callbackCleanup(); @@ -738,6 +745,8 @@ int iocShutdown(void) iocState = iocVoid; iocBuildMode = buildServers; + + initHookAnnounce(initHookAfterShutdown); return 0; } diff --git a/modules/libcom/src/iocsh/initHooks.h b/modules/libcom/src/iocsh/initHooks.h index 429a768db..261568e9d 100644 --- a/modules/libcom/src/iocsh/initHooks.h +++ b/modules/libcom/src/iocsh/initHooks.h @@ -47,6 +47,14 @@ typedef enum { initHookAfterDatabasePaused, initHookAfterIocPaused, /* End of iocPause command */ + initHookAtShutdown, /* Start of iocShutdown commands */ + initHookAfterCloseLinks, + initHookAfterStopScan, /* triggered only by unittest code. testIocShutdownOk() */ + initHookAfterStopCallback, /* triggered only by unittest code. testIocShutdownOk() */ + initHookAfterStopLinks, + initHookBeforeFree, /* triggered only by unittest code. testIocShutdownOk() */ + initHookAfterShutdown, /* End of iocShutdown commands */ + /* Deprecated states, provided for backwards compatibility. * These states are announced at the same point they were before, * but will not be repeated if the IOC gets paused and restarted.