chiark / gitweb /
sd-bus: avoid potential memory leaks
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2018 07:21:29 +0000 (16:21 +0900)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:58:49 +0000 (07:58 +0200)
src/libelogind/sd-bus/sd-bus.c

index 072b3df0c1e44fc508e45ab425ab6adf8cd18fbd..f11cdce850b8d73cd7c8751b826cd49094900c7e 100644 (file)
 #include <netdb.h>
 #include <poll.h>
 #include <pthread.h>
-//#include <signal.h>
 #include <stdlib.h>
 #include <sys/mman.h>
-//#include <sys/wait.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
@@ -1109,13 +1107,6 @@ static int bus_parse_next_address(sd_bus *b) {
         return 1;
 }
 
-static void bus_kill_exec(sd_bus *bus) {
-        if (pid_is_valid(bus->busexec_pid) > 0) {
-                sigterm_wait(bus->busexec_pid);
-                bus->busexec_pid = 0;
-        }
-}
-
 static int bus_start_address(sd_bus *b) {
         int r;
 
@@ -1125,8 +1116,6 @@ static int bus_start_address(sd_bus *b) {
                 bus_close_io_fds(b);
                 bus_close_inotify_fd(b);
 
-                bus_kill_exec(b);
-
                 /* If you provide multiple different bus-addresses, we
                  * try all of them in order and use the first one that
                  * succeeds. */
@@ -1540,9 +1529,6 @@ _public_ void sd_bus_close(sd_bus *bus) {
         if (bus_pid_changed(bus))
                 return;
 
-        /* Don't leave ssh hanging around */
-        bus_kill_exec(bus);
-
         bus_set_state(bus, BUS_CLOSED);
 
         sd_bus_detach_event(bus);
@@ -1560,9 +1546,6 @@ _public_ sd_bus* sd_bus_flush_close_unref(sd_bus *bus) {
         if (!bus)
                 return NULL;
 
-        /* Have to do this before flush() to prevent hang */
-        bus_kill_exec(bus);
-
         sd_bus_flush(bus);
         sd_bus_close(bus);