chiark / gitweb /
mount: don't fire PropertiesChanged signals for mounts that are stopped
[elogind.git] / src / core / manager.c
index b58b98c137eb655f6d4a6b20cd28cc32bcb2c549..f5801b4749512d984422e1d4fd63ba4fe2284442 100644 (file)
@@ -105,7 +105,7 @@ static int manager_watch_jobs_in_progress(Manager *m) {
                 return 0;
 
         next = now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC;
-        return sd_event_add_monotonic(m->event, next, 0, manager_dispatch_jobs_in_progress, m, &m->jobs_in_progress_event_source);
+        return sd_event_add_monotonic(m->event, &m->jobs_in_progress_event_source, next, 0, manager_dispatch_jobs_in_progress, m);
 }
 
 #define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED_ON)-1) + sizeof(ANSI_HIGHLIGHT_RED_ON)-1 + 2*(sizeof(ANSI_HIGHLIGHT_OFF)-1))
@@ -209,7 +209,7 @@ static int manager_watch_idle_pipe(Manager *m) {
         if (m->idle_pipe[2] < 0)
                 return 0;
 
-        r = sd_event_add_io(m->event, m->idle_pipe[2], EPOLLIN, manager_dispatch_idle_pipe_fd, m, &m->idle_pipe_event_source);
+        r = sd_event_add_io(m->event, &m->idle_pipe_event_source, m->idle_pipe[2], EPOLLIN, manager_dispatch_idle_pipe_fd, m);
         if (r < 0) {
                 log_error("Failed to watch idle pipe: %s", strerror(-r));
                 return r;
@@ -253,7 +253,7 @@ static int manager_setup_time_change(Manager *m) {
                 return 0;
         }
 
-        r = sd_event_add_io(m->event, m->time_change_fd, EPOLLIN, manager_dispatch_time_change_fd, m, &m->time_change_event_source);
+        r = sd_event_add_io(m->event, &m->time_change_event_source, m->time_change_fd, EPOLLIN, manager_dispatch_time_change_fd, m);
         if (r < 0) {
                 log_error("Failed to create time change event source: %s", strerror(-r));
                 return r;
@@ -340,7 +340,7 @@ static int manager_setup_signals(Manager *m) {
         if (m->signal_fd < 0)
                 return -errno;
 
-        r = sd_event_add_io(m->event, m->signal_fd, EPOLLIN, manager_dispatch_signal_fd, m, &m->signal_event_source);
+        r = sd_event_add_io(m->event, &m->signal_event_source, m->signal_fd, EPOLLIN, manager_dispatch_signal_fd, m);
         if (r < 0)
                 return r;
 
@@ -455,7 +455,7 @@ int manager_new(SystemdRunningAs running_as, Manager **_m) {
         if (r < 0)
                 goto fail;
 
-        r = sd_event_add_defer(m->event, manager_dispatch_run_queue, m, &m->run_queue_event_source);
+        r = sd_event_add_defer(m->event, &m->run_queue_event_source, manager_dispatch_run_queue, m);
         if (r < 0)
                 goto fail;
 
@@ -552,7 +552,7 @@ static int manager_setup_notify(Manager *m) {
         }
 
         if (!m->notify_event_source) {
-                r = sd_event_add_io(m->event, m->notify_fd, EPOLLIN, manager_dispatch_notify_fd, m, &m->notify_event_source);
+                r = sd_event_add_io(m->event, &m->notify_event_source, m->notify_fd, EPOLLIN, manager_dispatch_notify_fd, m);
                 if (r < 0) {
                         log_error("Failed to allocate notify event source: %s", strerror(-r));
                         return -errno;
@@ -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) {
 
@@ -1916,7 +1903,7 @@ int manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j) {
 void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
 
 #ifdef HAVE_AUDIT
-        char *p;
+        _cleanup_free_ char *p = NULL;
         int audit_fd;
 
         audit_fd = get_audit_fd();
@@ -1949,17 +1936,19 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
                 } else
                         log_warning("Failed to send audit message: %m");
         }
-
-        free(p);
 #endif
 
 }
 
 void manager_send_unit_plymouth(Manager *m, Unit *u) {
-        int fd = -1;
-        union sockaddr_union sa;
+        union sockaddr_union sa = {
+                .un.sun_family = AF_UNIX,
+                .un.sun_path = "\0/org/freedesktop/plymouthd",
+        };
+
         int n = 0;
-        char *message = NULL;
+        _cleanup_free_ char *message = NULL;
+        _cleanup_close_ int fd = -1;
 
         /* Don't generate plymouth events if the service was already
          * started and we're just deserializing */
@@ -1985,46 +1974,22 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
                 return;
         }
 
-        zero(sa);
-        sa.sa.sa_family = AF_UNIX;
-        strncpy(sa.un.sun_path+1, "/org/freedesktop/plymouthd", sizeof(sa.un.sun_path)-1);
         if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1)) < 0) {
 
-                if (errno != EPIPE &&
-                    errno != EAGAIN &&
-                    errno != ENOENT &&
-                    errno != ECONNREFUSED &&
-                    errno != ECONNRESET &&
-                    errno != ECONNABORTED)
+                if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
                         log_error("connect() failed: %m");
-
-                goto finish;
+                return;
         }
 
         if (asprintf(&message, "U\002%c%s%n", (int) (strlen(u->id) + 1), u->id, &n) < 0) {
                 log_oom();
-                goto finish;
+                return;
         }
 
         errno = 0;
-        if (write(fd, message, n + 1) != n + 1) {
-
-                if (errno != EPIPE &&
-                    errno != EAGAIN &&
-                    errno != ENOENT &&
-                    errno != ECONNREFUSED &&
-                    errno != ECONNRESET &&
-                    errno != ECONNABORTED)
+        if (write(fd, message, n + 1) != n + 1)
+                if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
                         log_error("Failed to write Plymouth message: %m");
-
-                goto finish;
-        }
-
-finish:
-        if (fd >= 0)
-                close_nointr_nofail(fd);
-
-        free(message);
 }
 
 void manager_dispatch_bus_name_owner_changed(