]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Add code to remove pid files and to log killing of clients
authorShawn Routhier <sar@isc.org>
Wed, 7 May 2014 15:03:19 +0000 (08:03 -0700)
committerShawn Routhier <sar@isc.org>
Wed, 7 May 2014 15:03:19 +0000 (08:03 -0700)
RELNOTES
client/dhclient.c
relay/dhcrelay.c
server/dhcpd.c

index e8aa5be4f06da7b135670d9e372dd526e38dc3e4..c5b4ccf430bc2f316c7cd2ad8ac00e81e014095b 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -103,6 +103,11 @@ by Eric Young (eay@cryptsoft.com).
   Thanks to Jiri Popelka at Red Hat for the bug and fix.
   [ISC-Bugs #21238
 
+- Add a log entry when killing a client and remove the PID files
+  when a server, relay or client are killed.
+  [ISC-Bugs #16970]
+  [ISC-Bugs #17258]
+
                        Changes since 4.3.0rc1
 
 - None
index 5f6ed00f3360967533118c2144a89032e46cb823..df87a93d1ebe452d2fb10753927b28b149aec443 100644 (file)
@@ -408,8 +408,10 @@ main(int argc, char **argv) {
                        e = fscanf(pidfd, "%ld\n", &temp);
                        oldpid = (pid_t)temp;
 
-                       if (e != 0 && e != EOF) {
-                               if (oldpid && (kill(oldpid, SIGTERM) == 0)) {
+                       if (e != 0 && e != EOF && oldpid) {
+                               if (kill(oldpid, SIGTERM) == 0) {
+                                       log_info("Killed old client process");
+                                       (void) unlink(path_dhclient_pid);
                                        /*
                                         * wait for the old process to
                                         * cleanly terminate.
@@ -418,6 +420,9 @@ main(int argc, char **argv) {
                                         * the parent can be signaled...
                                         */
                                        sleep(1);
+                               } else if (errno == ESRCH) {
+                                       log_info("Removed stale PID file");
+                                       (void) unlink(path_dhclient_pid);
                                }
                        }
                        fclose(pidfd);
@@ -3867,6 +3872,9 @@ unsigned cons_agent_information_options (cfg_options, outpacket,
 
 static void shutdown_exit (void *foo)
 {
+       /* get rid of the pid if we can */
+       if (no_pid_file == ISC_FALSE)
+               (void) unlink(path_dhclient_pid);
        exit (0);
 }
 
index ccb9768b85f81f28e76eec0563aa1e1caaab5d1b..11751d212c75e7335897d77021b1329cd94be8f8 100644 (file)
@@ -1717,5 +1717,9 @@ dhcp_set_control_state(control_object_state_t oldstate,
                       control_object_state_t newstate) {
        if (newstate != server_shutdown)
                return ISC_R_SUCCESS;
+
+       if (no_pid_file == ISC_FALSE)
+               (void) unlink(path_dhcrelay_pid);
+
        exit(0);
 }
index 2ae031e6fc672b003bab5f8f1b304d4adc0477c2..28cc56292b14bdbab6f1963bb7c236afe03cffcf 100644 (file)
@@ -1354,6 +1354,8 @@ static isc_result_t dhcp_io_shutdown_countdown (void *vlp)
            free_everything ();
            omapi_print_dmalloc_usage_by_caller ();
 #endif
+           if (no_pid_file == ISC_FALSE)
+                   (void) unlink(path_dhcpd_pid);
            exit (0);
        }               
 #else
@@ -1363,6 +1365,8 @@ static isc_result_t dhcp_io_shutdown_countdown (void *vlp)
                free_everything ();
                omapi_print_dmalloc_usage_by_caller (); 
 #endif
+               if (no_pid_file == ISC_FALSE)
+                       (void) unlink(path_dhcpd_pid);
                exit (0);
        }
 #endif