chiark / gitweb /
util: close all fds before freezing execution
authorLennart Poettering <lennart@poettering.net>
Thu, 10 Mar 2011 23:52:13 +0000 (00:52 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Mar 2011 23:52:31 +0000 (00:52 +0100)
TODO
src/dbus-common.c
src/util.c

diff --git a/TODO b/TODO
index f2e3be41630486e12575427ea8be29365ecc38c4..daa96773add2b9e3bfaa6ac0ca3e0ec4ccfbcad3 100644 (file)
--- a/TODO
+++ b/TODO
@@ -22,8 +22,6 @@ F15:
 
 * bind mounts are ignored
 
 
 * bind mounts are ignored
 
-* SIGALRM in systemctl
-
 * 0595f9a1c182a84581749823ef47c5f292e545f9 is borked, freezes shutdown
 
 Features:
 * 0595f9a1c182a84581749823ef47c5f292e545f9 is borked, freezes shutdown
 
 Features:
index 80b2115e1672e9db287477db1a3f1803e84a2e26..809ea0f67a9ec310d0b9165167f6e0cae879ca40 100644 (file)
@@ -77,6 +77,9 @@ int bus_connect(DBusBusType t, DBusConnection **_bus, bool *private, DBusError *
                         return -EACCES;
                 }
 
                         return -EACCES;
                 }
 
+                /* This complexity should probably move into D-Bus itself:
+                 *
+                 * https://bugs.freedesktop.org/show_bug.cgi?id=35189 */
                 begin = tstamp = now(CLOCK_MONOTONIC);
                 for (;;) {
 
                 begin = tstamp = now(CLOCK_MONOTONIC);
                 for (;;) {
 
index c02b39e0ad5fb896d1c80977328b9762b2678e3c..c9366c4a393fe9239fd038e00f19f074eb020d20 100644 (file)
@@ -1815,8 +1815,9 @@ int close_all_fds(const int except[], unsigned n_except) {
                 if (ignore_file(de->d_name))
                         continue;
 
                 if (ignore_file(de->d_name))
                         continue;
 
-                if ((r = safe_atoi(de->d_name, &fd)) < 0)
-                        goto finish;
+                if (safe_atoi(de->d_name, &fd) < 0)
+                        /* Let's better ignore this, just in case */
+                        continue;
 
                 if (fd < 3)
                         continue;
 
                 if (fd < 3)
                         continue;
@@ -1839,16 +1840,13 @@ int close_all_fds(const int except[], unsigned n_except) {
                                 continue;
                 }
 
                                 continue;
                 }
 
-                if ((r = close_nointr(fd)) < 0) {
+                if (close_nointr(fd) < 0) {
                         /* Valgrind has its own FD and doesn't want to have it closed */
                         /* Valgrind has its own FD and doesn't want to have it closed */
-                        if (errno != EBADF)
-                                goto finish;
+                        if (errno != EBADF && r == 0)
+                                r = -errno;
                 }
         }
 
                 }
         }
 
-        r = 0;
-
-finish:
         closedir(d);
         return r;
 }
         closedir(d);
         return r;
 }
@@ -3619,6 +3617,10 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid) {
 }
 
 void freeze(void) {
 }
 
 void freeze(void) {
+
+        /* Make sure nobody waits for us on a socket anymore */
+        close_all_fds(NULL, 0);
+
         sync();
 
         for (;;)
         sync();
 
         for (;;)