X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-session.c;h=548f049202e9c1baecb2b66ac1830f4e1c62a648;hb=2141e47892cadfd48ad0896ae66831e704ec068e;hp=f661cc8b8d2aa1720b70bf6b349348b93b9b8239;hpb=ba4c5d93b73ef7bba0ae0c6bf2b36a42360f7a34;p=elogind.git diff --git a/src/login/logind-session.c b/src/login/logind-session.c index f661cc8b8..548f04920 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -480,7 +480,7 @@ static int session_start_scope(Session *s) { if (!s->scope) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_free_ char *description = NULL; - char *scope, *job; + char *scope, *job = NULL; description = strjoin("Session ", s->id, " of user ", s->user->name, NULL); if (!description) @@ -565,9 +565,9 @@ 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; + char *job = NULL; int r; assert(s); @@ -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; } @@ -683,7 +683,7 @@ void session_release(Session *s) { return; if (!s->timer_event_source) - sd_event_add_monotonic(s->manager->event, now(CLOCK_MONOTONIC) + RELEASE_USEC, 0, release_timeout_callback, s, &s->timer_event_source); + sd_event_add_monotonic(s->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + RELEASE_USEC, 0, release_timeout_callback, s); } bool session_is_active(Session *s) { @@ -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; } @@ -844,7 +844,7 @@ int session_create_fifo(Session *s) { } if (!s->fifo_event_source) { - r = sd_event_add_io(s->manager->event, s->fifo_fd, 0, session_dispatch_fifo, s, &s->fifo_event_source); + r = sd_event_add_io(s->manager->event, &s->fifo_event_source, s->fifo_fd, 0, session_dispatch_fifo, s); if (r < 0) return r; @@ -915,10 +915,11 @@ void session_add_to_gc_queue(Session *s) { SessionState session_get_state(Session *s) { assert(s); + /* always check closing first */ if (s->stopping || s->timer_event_source) return SESSION_CLOSING; - if (s->scope_job) + if (s->scope_job || s->fifo_fd < 0) return SESSION_OPENING; if (session_is_active(s)) @@ -985,7 +986,7 @@ void session_mute_vt(Session *s) { sigaddset(&mask, SIGUSR1); sigprocmask(SIG_BLOCK, &mask, NULL); - r = sd_event_add_signal(s->manager->event, SIGUSR1, session_vt_fn, s, &s->vt_source); + r = sd_event_add_signal(s->manager->event, &s->vt_source, SIGUSR1, session_vt_fn, s); if (r < 0) goto error; @@ -1007,7 +1008,7 @@ error: } void session_restore_vt(Session *s) { - _cleanup_free_ char *utf8; + _cleanup_free_ char *utf8 = NULL; int vt, kb = K_XLATE; struct vt_mode mode = { 0 };