chiark / gitweb /
exec: replace OOMAdjust= by OOMScoreAdjust= to follow new kernel interface
[elogind.git] / src / initctl.c
index 3de7fcd42e89242b6dd1de24161bc6e91396ccde..12b0e894fe6cc33e5d0f56cd9c5e50e9d22f1841 100644 (file)
@@ -1,4 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
 /***
   This file is part of systemd.
@@ -41,6 +41,7 @@
 #include "initreq.h"
 #include "special.h"
 #include "sd-daemon.h"
+#include "dbus-common.h"
 
 #define SERVER_FD_MAX 16
 #define TIMEOUT ((int) (10*MSEC_PER_SEC))
@@ -118,12 +119,12 @@ static void change_runlevel(Server *s, int runlevel) {
                                       DBUS_TYPE_STRING, &target,
                                       DBUS_TYPE_STRING, &replace,
                                       DBUS_TYPE_INVALID)) {
-                log_error("Could not attach target and flag information to signal message.");
+                log_error("Could not attach target and flag information to message.");
                 goto finish;
         }
 
         if (!(reply = dbus_connection_send_with_reply_and_block(s->bus, m, -1, &error))) {
-                log_error("Failed to start unit: %s", error.message);
+                log_error("Failed to start unit: %s", bus_error_message(&error));
                 goto finish;
         }
 
@@ -231,7 +232,7 @@ static void server_done(Server *s) {
                 close_nointr_nofail(s->epoll_fd);
 
         if (s->bus) {
-               dbus_connection_set_exit_on_disconnect(s->bus, FALSE);
+               dbus_connection_close(s->bus);
                dbus_connection_unref(s->bus);
         }
 }
@@ -290,14 +291,14 @@ static int server_init(Server *s, unsigned n_sockets) {
                         goto fail;
                 }
 
-                f->fd = SD_LISTEN_FDS_START+i;
+                f->fd = fd;
                 LIST_PREPEND(Fifo, fifo, s->fifos, f);
                 f->server = s;
                 s->n_fifos ++;
         }
 
-        if (!(s->bus = dbus_connection_open("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
-                log_error("Failed to get D-Bus connection: %s", error.message);
+        if (bus_connect(DBUS_BUS_SYSTEM, &s->bus, NULL, &error) < 0) {
+                log_error("Failed to get D-Bus connection: %s", bus_error_message(&error));
                 goto fail;
         }
 
@@ -348,8 +349,7 @@ int main(int argc, char *argv[]) {
 
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
         log_parse_environment();
-
-        log_info("systemd-initctl running as pid %lu", (unsigned long) getpid());
+        log_open();
 
         if ((n = sd_listen_fds(true)) < 0) {
                 log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
@@ -364,6 +364,8 @@ int main(int argc, char *argv[]) {
         if (server_init(&server, (unsigned) n) < 0)
                 return 2;
 
+        log_debug("systemd-initctl running as pid %lu", (unsigned long) getpid());
+
         sd_notify(false,
                   "READY=1\n"
                   "STATUS=Processing requests...");
@@ -386,19 +388,20 @@ int main(int argc, char *argv[]) {
                 if (k <= 0)
                         break;
 
-                if ((k = process_event(&server, &event)) < 0)
+                if (process_event(&server, &event) < 0)
                         goto fail;
         }
+
         r = 0;
 
+        log_debug("systemd-initctl stopped as pid %lu", (unsigned long) getpid());
+
 fail:
         sd_notify(false,
                   "STATUS=Shutting down...");
 
         server_done(&server);
 
-        log_info("systemd-initctl stopped as pid %lu", (unsigned long) getpid());
-
         dbus_shutdown();
 
         return r;