summaryrefslogtreecommitdiff
path: root/omapip
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2013-11-14 12:55:10 -0800
committerShawn Routhier <sar@isc.org>2013-11-14 12:55:10 -0800
commit0895c955d16a957107771e442397c6260d92cbc2 (patch)
treebeb3d593cb202f75f92bad953fb1eaef1a875671 /omapip
parentf88446f16b9b3be36492f78b0f66a4166e459896 (diff)
downloadisc-dhcp-0895c955d16a957107771e442397c6260d92cbc2.tar.gz
[master] Fix up the gentle shutdown code to handle failover
This patch modifies the gentle failover patch to be cleaner and to handle failover peers better.
Diffstat (limited to 'omapip')
-rw-r--r--omapip/isclib.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/omapip/isclib.c b/omapip/isclib.c
index 5dcb12c0..afab262c 100644
--- a/omapip/isclib.c
+++ b/omapip/isclib.c
@@ -31,6 +31,7 @@
#include <signal.h>
dhcp_context_t dhcp_gbl_ctx;
+int shutdown_signal = 0;
void
isclib_cleanup(void)
@@ -225,13 +226,17 @@ isclib_make_dst_key(char *inname,
*/
void dhcp_signal_handler(int signal) {
isc_appctx_t *ctx = dhcp_gbl_ctx.actx;
- if (ctx && ctx->methods && ctx->methods->ctxshutdown) {
- /*
- * Let's not use standard log facilities here. They may not be
- * signal safe, e.g. we could get the signal in the middle of
- * another log call
- */
- printf("Received signal %d, initiating shutdown.\n", signal);
- ctx->methods->ctxshutdown(ctx);
+ int prev = shutdown_signal;
+
+ if (prev != 0) {
+ /* Already in shutdown. */
+ return;
+ }
+ /* Possible race but does it matter? */
+ shutdown_signal = signal;
+
+ /* Use reload (aka suspend) for easier dispatch() reenter. */
+ if (ctx && ctx->methods && ctx->methods->ctxsuspend) {
+ (void) isc_app_ctxsuspend(ctx);
}
}