[systemd-devel] [PATCH 6/7] logind: add user_is_opening() and session_is_opening()
Djalal Harouni
tixxdz at opendz.org
Thu Feb 6 12:37:19 PST 2014
Add the user_is_opening() and session_is_opening() functions. These
functions will check their appropriate 'opening' flag to see if we are
in the middel of the opening state.
This patch is preparation for the next patch which will use it to guard
match_job_remove() from calling session_jobs_reply() and
session_send_create_reply() during SESSION_CLOSING.
---
src/login/logind-session.c | 8 +++++++-
src/login/logind-session.h | 1 +
src/login/logind-user.c | 8 +++++++-
src/login/logind-user.h | 1 +
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 848e8a1..215f2b8 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -647,6 +647,12 @@ int session_finalize(Session *s) {
return r;
}
+bool session_is_opening(Session *s) {
+ assert(s);
+
+ return s->scope_opening;
+}
+
bool session_is_active(Session *s) {
assert(s);
@@ -882,7 +888,7 @@ void session_add_to_gc_queue(Session *s) {
SessionState session_get_state(Session *s) {
assert(s);
- if (s->scope_opening)
+ if (session_is_opening(s))
return SESSION_OPENING;
if (s->fifo_fd < 0)
diff --git a/src/login/logind-session.h b/src/login/logind-session.h
index 205491a..964306d 100644
--- a/src/login/logind-session.h
+++ b/src/login/logind-session.h
@@ -129,6 +129,7 @@ void session_set_user(Session *s, User *u);
bool session_check_gc(Session *s, bool drop_not_started);
void session_add_to_gc_queue(Session *s);
int session_activate(Session *s);
+bool session_is_opening(Session *s);
bool session_is_active(Session *s);
int session_get_idle_hint(Session *s, dual_timestamp *t);
void session_set_idle_hint(Session *s, bool b);
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 9ed216d..cf9c948 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -635,6 +635,12 @@ void user_add_to_gc_queue(User *u) {
u->in_gc_queue = true;
}
+bool user_is_opening(User *u) {
+ assert(u);
+
+ return u->slice_opening || u->service_opening;
+}
+
UserState user_get_state(User *u) {
Session *i;
SessionState session_state;
@@ -642,7 +648,7 @@ UserState user_get_state(User *u) {
assert(u);
- if (u->slice_opening || u->service_opening)
+ if (user_is_opening(u))
return USER_OPENING;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
diff --git a/src/login/logind-user.h b/src/login/logind-user.h
index ac43361..2728168 100644
--- a/src/login/logind-user.h
+++ b/src/login/logind-user.h
@@ -75,6 +75,7 @@ void user_add_to_gc_queue(User *u);
int user_start(User *u);
int user_stop(User *u);
int user_finalize(User *u);
+bool user_is_opening(User *u);
UserState user_get_state(User *u);
int user_get_idle_hint(User *u, dual_timestamp *t);
int user_save(User *u);
--
1.8.3.1
More information about the systemd-devel
mailing list