[systemd-commits] 3 commits - src/core src/journal src/login src/shared

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Tue Feb 11 16:32:34 PST 2014


 src/core/job.c                  |    3 ---
 src/core/manager.c              |   21 ++++-----------------
 src/journal/journald-server.c   |    2 +-
 src/login/logind-dbus.c         |    9 +++++----
 src/login/logind-seat-dbus.c    |    2 +-
 src/login/logind-seat.c         |    8 ++++----
 src/login/logind-seat.h         |    4 ++--
 src/login/logind-session-dbus.c |    2 +-
 src/login/logind-session.c      |   12 ++++++------
 src/login/logind-session.h      |    2 +-
 src/login/logind-user-dbus.c    |    2 +-
 src/login/logind-user.c         |    4 ++--
 src/login/logind-user.h         |    2 +-
 src/login/logind.c              |    6 +++---
 src/shared/log.c                |   17 +++++++++++++++++
 src/shared/log.h                |    5 ++++-
 16 files changed, 53 insertions(+), 48 deletions(-)

New commits:
commit a87105a38637355bd6d648036f0369a1a9546ae9
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Feb 8 17:22:13 2014 -0500

    logind: ignore PropertiesChanged signals for jobs
    
    Otherwise we get a (harmless) message like:
    systemd-logind[30845]: Failed to process message [type=signal sender=:1.36 path=/org/freedesktop/systemd1/job/4674 interface=org.freedesktop.DBus.Properties member=PropertiesChanged signature=sa{sv}as]: Invalid argument

diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 08e53c3..bd0de33 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2047,7 +2047,8 @@ int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdat
 
         r = unit_name_from_dbus_path(path, &unit);
         if (r < 0)
-                return r;
+                /* quietly ignore non-units paths */
+                return r == -EINVAL ? 0 : r;
 
         session = hashmap_get(m->session_units, unit);
         if (session)

commit 9bb69af4f2823fdd30902f5ffd959e9b041feb53
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Feb 8 20:29:56 2014 -0500

    logind: always kill session when termination is requested
    
    KillUserProcesses=yes/no should be ignored when termination is
    explicitly requested.

diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 7e96a04..08e53c3 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -939,7 +939,7 @@ static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void *
         if (!session)
                 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name);
 
-        r = session_stop(session);
+        r = session_stop(session, true);
         if (r < 0)
                 return r;
 
@@ -964,7 +964,7 @@ static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *use
         if (!user)
                 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid);
 
-        r = user_stop(user);
+        r = user_stop(user, true);
         if (r < 0)
                 return r;
 
@@ -989,7 +989,7 @@ static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *use
         if (!seat)
                 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", name);
 
-        r = seat_stop_sessions(seat);
+        r = seat_stop_sessions(seat, true);
         if (r < 0)
                 return r;
 
diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c
index 909007c..26cddfe 100644
--- a/src/login/logind-seat-dbus.c
+++ b/src/login/logind-seat-dbus.c
@@ -201,7 +201,7 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata
         assert(message);
         assert(s);
 
-        r = seat_stop_sessions(s);
+        r = seat_stop_sessions(s, true);
         if (r < 0)
                 return r;
 
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index c7f112a..631be5f 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -418,7 +418,7 @@ int seat_start(Seat *s) {
         return 0;
 }
 
-int seat_stop(Seat *s) {
+int seat_stop(Seat *s, bool force) {
         int r = 0;
 
         assert(s);
@@ -430,7 +430,7 @@ int seat_stop(Seat *s) {
                            "MESSAGE=Removed seat %s.", s->id,
                            NULL);
 
-        seat_stop_sessions(s);
+        seat_stop_sessions(s, force);
 
         unlink(s->state_file);
         seat_add_to_gc_queue(s);
@@ -443,14 +443,14 @@ int seat_stop(Seat *s) {
         return r;
 }
 
-int seat_stop_sessions(Seat *s) {
+int seat_stop_sessions(Seat *s, bool force) {
         Session *session;
         int r = 0, k;
 
         assert(s);
 
         LIST_FOREACH(sessions_by_seat, session, s->sessions) {
-                k = session_stop(session);
+                k = session_stop(session, force);
                 if (k < 0)
                         r = k;
         }
diff --git a/src/login/logind-seat.h b/src/login/logind-seat.h
index 9e21e3a..9e469d4 100644
--- a/src/login/logind-seat.h
+++ b/src/login/logind-seat.h
@@ -80,8 +80,8 @@ bool seat_can_graphical(Seat *s);
 int seat_get_idle_hint(Seat *s, dual_timestamp *t);
 
 int seat_start(Seat *s);
-int seat_stop(Seat *s);
-int seat_stop_sessions(Seat *s);
+int seat_stop(Seat *s, bool force);
+int seat_stop_sessions(Seat *s, bool force);
 
 bool seat_check_gc(Seat *s, bool drop_not_started);
 void seat_add_to_gc_queue(Seat *s);
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index 7ee4956..f9305dd 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -188,7 +188,7 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata
         assert(message);
         assert(s);
 
-        r = session_stop(s);
+        r = session_stop(s, true);
         if (r < 0)
                 return r;
 
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index f661cc8..d4742e1 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -565,7 +565,7 @@ int session_start(Session *s) {
         return 0;
 }
 
-static int session_stop_scope(Session *s) {
+static int session_stop_scope(Session *s, bool force) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         char *job;
         int r;
@@ -575,7 +575,7 @@ static int session_stop_scope(Session *s) {
         if (!s->scope)
                 return 0;
 
-        if (manager_shall_kill(s->manager, s->user->name)) {
+        if (force || manager_shall_kill(s->manager, s->user->name)) {
                 r = manager_stop_unit(s->manager, s->scope, &error, &job);
                 if (r < 0) {
                         log_error("Failed to stop session scope: %s", bus_error_message(&error, r));
@@ -595,7 +595,7 @@ static int session_stop_scope(Session *s) {
         return 0;
 }
 
-int session_stop(Session *s) {
+int session_stop(Session *s, bool force) {
         int r;
 
         assert(s);
@@ -609,7 +609,7 @@ int session_stop(Session *s) {
         session_remove_fifo(s);
 
         /* Kill cgroup */
-        r = session_stop_scope(s);
+        r = session_stop_scope(s, force);
 
         s->stopping = true;
 
@@ -672,7 +672,7 @@ static int release_timeout_callback(sd_event_source *es, uint64_t usec, void *us
         assert(es);
         assert(s);
 
-        session_stop(s);
+        session_stop(s, false);
         return 0;
 }
 
@@ -812,7 +812,7 @@ static int session_dispatch_fifo(sd_event_source *es, int fd, uint32_t revents,
         /* EOF on the FIFO means the session died abnormally. */
 
         session_remove_fifo(s);
-        session_stop(s);
+        session_stop(s, false);
 
         return 1;
 }
diff --git a/src/login/logind-session.h b/src/login/logind-session.h
index 42552bc..c9af5eb 100644
--- a/src/login/logind-session.h
+++ b/src/login/logind-session.h
@@ -136,7 +136,7 @@ int session_get_idle_hint(Session *s, dual_timestamp *t);
 void session_set_idle_hint(Session *s, bool b);
 int session_create_fifo(Session *s);
 int session_start(Session *s);
-int session_stop(Session *s);
+int session_stop(Session *s, bool force);
 int session_finalize(Session *s);
 void session_release(Session *s);
 int session_save(Session *s);
diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index 2d49b8b..18eea89 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -180,7 +180,7 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata
         assert(message);
         assert(u);
 
-        r = user_stop(u);
+        r = user_stop(u, true);
         if (r < 0)
                 return r;
 
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 06fdbb3..ac4a651 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -494,13 +494,13 @@ static int user_remove_runtime_path(User *u) {
         return r;
 }
 
-int user_stop(User *u) {
+int user_stop(User *u, bool force) {
         Session *s;
         int r = 0, k;
         assert(u);
 
         LIST_FOREACH(sessions_by_user, s, u->sessions) {
-                k = session_stop(s);
+                k = session_stop(s, force);
                 if (k < 0)
                         r = k;
         }
diff --git a/src/login/logind-user.h b/src/login/logind-user.h
index b0fefe9..f237d2a 100644
--- a/src/login/logind-user.h
+++ b/src/login/logind-user.h
@@ -72,7 +72,7 @@ void user_free(User *u);
 bool user_check_gc(User *u, bool drop_not_started);
 void user_add_to_gc_queue(User *u);
 int user_start(User *u);
-int user_stop(User *u);
+int user_stop(User *u, bool force);
 int user_finalize(User *u);
 UserState user_get_state(User *u);
 int user_get_idle_hint(User *u, dual_timestamp *t);
diff --git a/src/login/logind.c b/src/login/logind.c
index a6f84e8..5544099 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -862,7 +862,7 @@ void manager_gc(Manager *m, bool drop_not_started) {
                 seat->in_gc_queue = false;
 
                 if (!seat_check_gc(seat, drop_not_started)) {
-                        seat_stop(seat);
+                        seat_stop(seat, false);
                         seat_free(seat);
                 }
         }
@@ -874,7 +874,7 @@ void manager_gc(Manager *m, bool drop_not_started) {
                 /* First, if we are not closing yet, initiate stopping */
                 if (!session_check_gc(session, drop_not_started) &&
                     session_get_state(session) != SESSION_CLOSING)
-                        session_stop(session);
+                        session_stop(session, false);
 
                 /* Normally, this should make the session busy again,
                  * if it doesn't then let's get rid of it
@@ -891,7 +891,7 @@ void manager_gc(Manager *m, bool drop_not_started) {
 
                 if (!user_check_gc(user, drop_not_started) &&
                     user_get_state(user) != USER_CLOSING)
-                        user_stop(user);
+                        user_stop(user, false);
 
                 if (!user_check_gc(user, drop_not_started)) {
                         user_finalize(user);

commit 4daf54a851e4fb7ed1a13c3117bba12528fd2c7f
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sun Feb 9 20:08:55 2014 -0500

    journald: log provenience of signals

diff --git a/src/core/job.c b/src/core/job.c
index 941f956..feeb563 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -1118,9 +1118,6 @@ int job_get_timeout(Job *j, uint64_t *timeout) {
 
         *timeout = MIN(x, y);
 
-        log_info("job_get_timeout %s %d/%"PRIu64" %d/%"PRIu64" -> 1/%"PRIu64,
-                 j->unit->id, r, x, q, y, *timeout);
-
         return 1;
 }
 
diff --git a/src/core/manager.c b/src/core/manager.c
index f7e5cbd..388697c 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1532,23 +1532,10 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                         return -errno;
                 }
 
-                if (sfsi.ssi_pid > 0) {
-                        _cleanup_free_ char *p = NULL;
-
-                        get_process_comm(sfsi.ssi_pid, &p);
-
-                        log_full(sfsi.ssi_signo == SIGCHLD ||
-                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
-                                 ? LOG_DEBUG : LOG_INFO,
-                                 "Received SIG%s from PID "PID_FMT" (%s).",
-                                 signal_to_string(sfsi.ssi_signo),
-                                 sfsi.ssi_pid, strna(p));
-                } else
-                        log_full(sfsi.ssi_signo == SIGCHLD ||
-                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
-                                 ? LOG_DEBUG : LOG_INFO,
-                                 "Received SIG%s.",
-                                 signal_to_string(sfsi.ssi_signo));
+                log_received_signal(sfsi.ssi_signo == SIGCHLD ||
+                                    (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+                                    ? LOG_DEBUG : LOG_INFO,
+                                    &sfsi);
 
                 switch (sfsi.ssi_signo) {
 
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index d3a1c57..9ca3859 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1251,7 +1251,7 @@ static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *
 
         assert(s);
 
-        log_info("Received SIG%s", signal_to_string(si->ssi_signo));
+        log_received_signal(LOG_INFO, si);
 
         sd_event_exit(s->event, 0);
         return 0;
diff --git a/src/shared/log.c b/src/shared/log.c
index 2a075ff..ee20921 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -973,3 +973,20 @@ static const char *const log_target_table[] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP(log_target, LogTarget);
+
+void log_received_signal(int level, const struct signalfd_siginfo *si) {
+        if (si->ssi_pid > 0) {
+                _cleanup_free_ char *p = NULL;
+
+                get_process_comm(si->ssi_pid, &p);
+
+                log_full(level,
+                         "Received SIG%s from PID "PID_FMT" (%s).",
+                         signal_to_string(si->ssi_signo),
+                         si->ssi_pid, strna(p));
+        } else
+                log_full(level,
+                         "Received SIG%s.",
+                         signal_to_string(si->ssi_signo));
+
+}
diff --git a/src/shared/log.h b/src/shared/log.h
index 3dcfa11..6a0f673 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -21,9 +21,10 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <syslog.h>
 #include <stdbool.h>
 #include <stdarg.h>
+#include <syslog.h>
+#include <sys/signalfd.h>
 #include <errno.h>
 
 #include "macro.h"
@@ -167,3 +168,5 @@ const char *log_target_to_string(LogTarget target) _const_;
 LogTarget log_target_from_string(const char *s) _pure_;
 
 #define MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
+
+void log_received_signal(int level, const struct signalfd_siginfo *si);



More information about the systemd-commits mailing list