summaryrefslogtreecommitdiff
path: root/client/dhclient.c
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 /client/dhclient.c
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 'client/dhclient.c')
-rw-r--r--client/dhclient.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/client/dhclient.c b/client/dhclient.c
index f131e393..97b86a6f 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -708,6 +708,7 @@ main(int argc, char **argv) {
/* Start dispatching packets and timeouts... */
dispatch();
+ /* In fact dispatch() never returns. */
return 0;
}
@@ -3944,6 +3945,20 @@ isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
struct client_state *client;
struct timeval tv;
+ if (newstate == server_shutdown) {
+ /* Re-entry */
+ if (shutdown_signal == SIGUSR1)
+ return ISC_R_SUCCESS;
+ /* Log shutdown on signal. */
+ if ((shutdown_signal == SIGINT) ||
+ (shutdown_signal == SIGTERM)) {
+ log_info("Received signal %d, initiating shutdown.",
+ shutdown_signal);
+ }
+ /* Mark it was called. */
+ shutdown_signal = SIGUSR1;
+ }
+
/* Do the right thing for each interface. */
for (ip = interfaces; ip; ip = ip -> next) {
for (client = ip -> client; client; client = client -> next) {