chiark / gitweb /
build-sys: initial support ALTLinux
[elogind.git] / src / swap.c
index ec9f157b156f7bb2e2d33dd46174d31e3759327d..9a253beea2c026ade0a5d77e3f67339716af9657 100644 (file)
@@ -36,6 +36,7 @@
 #include "dbus-swap.h"
 #include "special.h"
 #include "bus-errors.h"
+#include "exit-status.h"
 
 static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
         [SWAP_DEAD] = UNIT_INACTIVE,
@@ -199,9 +200,15 @@ static int swap_add_device_links(Swap *s) {
         else
                 return 0;
 
-        return unit_add_node_link(UNIT(s), s->what,
-                                  !p->noauto && p->nofail &&
-                                  s->meta.manager->running_as == MANAGER_SYSTEM);
+        if (is_device_path(s->what))
+                return unit_add_node_link(UNIT(s), s->what,
+                                          !p->noauto && p->nofail &&
+                                          s->meta.manager->running_as == MANAGER_SYSTEM);
+        else
+                /* File based swap devices need to be ordered after
+                 * remount-rootfs.service, since they might need a
+                 * writable file system. */
+                return unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_REMOUNT_ROOTFS_SERVICE, NULL, true);
 }
 
 static int swap_add_default_dependencies(Swap *s) {
@@ -495,7 +502,7 @@ static void swap_set_state(Swap *s, SwapState state) {
                           swap_state_to_string(old_state),
                           swap_state_to_string(state));
 
-        unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state]);
+        unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], true);
 }
 
 static int swap_coldplug(Unit *u) {
@@ -989,13 +996,23 @@ static void swap_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
                 break;
 
         case SWAP_ACTIVATING_SIGTERM:
-                log_warning("%s activation timed out. Killing.", u->meta.id);
-                swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, false);
+                if (s->exec_context.send_sigkill) {
+                        log_warning("%s activation timed out. Killing.", u->meta.id);
+                        swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, false);
+                } else {
+                        log_warning("%s activation timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+                        swap_enter_dead(s, false);
+                }
                 break;
 
         case SWAP_DEACTIVATING_SIGTERM:
-                log_warning("%s deactivation timed out. Killing.", u->meta.id);
-                swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, false);
+                if (s->exec_context.send_sigkill) {
+                        log_warning("%s deactivation timed out. Killing.", u->meta.id);
+                        swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, false);
+                } else {
+                        log_warning("%s deactivation timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+                        swap_enter_dead(s, false);
+                }
                 break;
 
         case SWAP_ACTIVATING_SIGKILL:
@@ -1073,7 +1090,7 @@ int swap_fd_event(Manager *m, int events) {
         assert(m);
         assert(events & EPOLLPRI);
 
-        if ((r == swap_load_proc_swaps(m, true)) < 0) {
+        if ((r = swap_load_proc_swaps(m, true)) < 0) {
                 log_error("Failed to reread /proc/swaps: %s", strerror(-r));
 
                 /* Reset flags, just in case, for late calls */