m->busnames = set_new(string_hash_func, string_compare_func);
if (!m->devices || !m->seats || !m->sessions || !m->users || !m->inhibitors || !m->buttons || !m->busnames ||
- !m->user_units || !m->session_units ||
- !m->busnames) {
+ !m->user_units || !m->session_units) {
manager_free(m);
return NULL;
}
return -errno;
}
- r = sd_event_add_io(m->event, m->console_active_fd, 0, manager_dispatch_console, m, &m->console_active_event_source);
+ r = sd_event_add_io(m->event, &m->console_active_event_source, m->console_active_fd, 0, manager_dispatch_console, m);
if (r < 0) {
log_error("Failed to watch foreground console");
return r;
if (r < 0)
return r;
- r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_seat_monitor), EPOLLIN, manager_dispatch_seat_udev, m, &m->udev_seat_event_source);
+ r = sd_event_add_io(m->event, &m->udev_seat_event_source, udev_monitor_get_fd(m->udev_seat_monitor), EPOLLIN, manager_dispatch_seat_udev, m);
if (r < 0)
return r;
if (r < 0)
return r;
- r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_device_monitor), EPOLLIN, manager_dispatch_device_udev, m, &m->udev_device_event_source);
+ r = sd_event_add_io(m->event, &m->udev_device_event_source, udev_monitor_get_fd(m->udev_device_monitor), EPOLLIN, manager_dispatch_device_udev, m);
if (r < 0)
return r;
if (r < 0)
return r;
- r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_button_monitor), EPOLLIN, manager_dispatch_button_udev, m, &m->udev_button_event_source);
+ r = sd_event_add_io(m->event, &m->udev_button_event_source, udev_monitor_get_fd(m->udev_button_monitor), EPOLLIN, manager_dispatch_button_udev, m);
if (r < 0)
return r;
}
if (r < 0)
return r;
- r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_vcsa_monitor), EPOLLIN, manager_dispatch_vcsa_udev, m, &m->udev_vcsa_event_source);
+ r = sd_event_add_io(m->event, &m->udev_vcsa_event_source, udev_monitor_get_fd(m->udev_vcsa_monitor), EPOLLIN, manager_dispatch_vcsa_udev, m);
if (r < 0)
return r;
}
seat->in_gc_queue = false;
if (!seat_check_gc(seat, drop_not_started)) {
- seat_stop(seat);
+ seat_stop(seat, false);
seat_free(seat);
}
}
LIST_REMOVE(gc_queue, m->session_gc_queue, session);
session->in_gc_queue = false;
+ /* 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, false);
+
+ /* Normally, this should make the session busy again,
+ * if it doesn't then let's get rid of it
+ * immediately */
if (!session_check_gc(session, drop_not_started)) {
- session_stop(session);
session_finalize(session);
session_free(session);
}
LIST_REMOVE(gc_queue, m->user_gc_queue, user);
user->in_gc_queue = false;
+ /* First step: queue stop jobs */
+ if (!user_check_gc(user, drop_not_started))
+ user_stop(user, false);
+
+ /* Second step: finalize user */
if (!user_check_gc(user, drop_not_started)) {
- user_stop(user);
user_finalize(user);
user_free(user);
}
if (!m->idle_action_event_source) {
- r = sd_event_add_monotonic(m->event, elapse, USEC_PER_SEC*30, manager_dispatch_idle_action, m, &m->idle_action_event_source);
+ r = sd_event_add_monotonic(m->event, &m->idle_action_event_source, elapse, USEC_PER_SEC*30, manager_dispatch_idle_action, m);
if (r < 0) {
log_error("Failed to add idle event source: %s", strerror(-r));
return r;