chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unit-name: style fix in unit_name_is_template()
[elogind.git]
/
src
/
login
/
logind-session.c
diff --git
a/src/login/logind-session.c
b/src/login/logind-session.c
index 58514ea0d2ccae3f1a8e2d8b6dafb13acfdab082..a43ecad2b1d46750213198e053cc955fc35e48cf 100644
(file)
--- a/
src/login/logind-session.c
+++ b/
src/login/logind-session.c
@@
-133,11
+133,13
@@
int session_save(Session *s) {
"UID=%lu\n"
"USER=%s\n"
"ACTIVE=%i\n"
"UID=%lu\n"
"USER=%s\n"
"ACTIVE=%i\n"
+ "STATE=%s\n"
"REMOTE=%i\n"
"KILL_PROCESSES=%i\n",
(unsigned long) s->user->uid,
s->user->name,
session_is_active(s),
"REMOTE=%i\n"
"KILL_PROCESSES=%i\n",
(unsigned long) s->user->uid,
s->user->name,
session_is_active(s),
+ session_state_to_string(session_get_state(s)),
s->remote,
s->kill_processes);
s->remote,
s->kill_processes);
@@
-373,7
+375,7
@@
static int session_link_x11_socket(Session *s) {
k = strspn(s->display+1, "0123456789");
f = new(char, sizeof("/tmp/.X11-unix/X") + k);
if (!f) {
k = strspn(s->display+1, "0123456789");
f = new(char, sizeof("/tmp/.X11-unix/X") + k);
if (!f) {
- log_error("Out of memory");
+ log_error("Out of memory
.
");
return -ENOMEM;
}
return -ENOMEM;
}
@@
-393,7
+395,7
@@
static int session_link_x11_socket(Session *s) {
t = strappend(s->user->runtime_path, "/X11-display");
if (!t) {
t = strappend(s->user->runtime_path, "/X11-display");
if (!t) {
- log_error("Out of memory");
+ log_error("Out of memory
.
");
free(f);
return -ENOMEM;
}
free(f);
return -ENOMEM;
}
@@
-467,7
+469,7
@@
static int session_create_cgroup(Session *s) {
if (!s->cgroup_path) {
if (asprintf(&p, "%s/%s", s->user->cgroup_path, s->id) < 0) {
if (!s->cgroup_path) {
if (asprintf(&p, "%s/%s", s->user->cgroup_path, s->id) < 0) {
- log_error("Out of memory");
+ log_error("Out of memory
.
");
return -ENOMEM;
}
} else
return -ENOMEM;
}
} else
@@
-668,7
+670,7
@@
static int session_unlink_x11_socket(Session *s) {
t = strappend(s->user->runtime_path, "/X11-display");
if (!t) {
t = strappend(s->user->runtime_path, "/X11-display");
if (!t) {
- log_error("Out of memory");
+ log_error("Out of memory
.
");
return -ENOMEM;
}
return -ENOMEM;
}
@@
-767,7
+769,7
@@
int session_get_idle_hint(Session *s, dual_timestamp *t) {
b = u + IDLE_THRESHOLD_USEC < n;
if (t)
b = u + IDLE_THRESHOLD_USEC < n;
if (t)
- dual_timestamp_from_realtime(t, u + b
? IDLE_THRESHOLD_USEC : 0
);
+ dual_timestamp_from_realtime(t, u + b
*IDLE_THRESHOLD_USEC
);
return b;
return b;
@@
-913,6
+915,18
@@
void session_add_to_gc_queue(Session *s) {
s->in_gc_queue = true;
}
s->in_gc_queue = true;
}
+SessionState session_get_state(Session *s) {
+ assert(s);
+
+ if (s->fifo_fd < 0)
+ return SESSION_CLOSING;
+
+ if (session_is_active(s))
+ return SESSION_ACTIVE;
+
+ return SESSION_ONLINE;
+}
+
int session_kill(Session *s, KillWho who, int signo) {
int r = 0;
Set *pid_set = NULL;
int session_kill(Session *s, KillWho who, int signo) {
int r = 0;
Set *pid_set = NULL;
@@
-954,6
+968,14
@@
int session_kill(Session *s, KillWho who, int signo) {
return r;
}
return r;
}
+static const char* const session_state_table[_SESSION_TYPE_MAX] = {
+ [SESSION_ONLINE] = "online",
+ [SESSION_ACTIVE] = "active",
+ [SESSION_CLOSING] = "closing"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(session_state, SessionState);
+
static const char* const session_type_table[_SESSION_TYPE_MAX] = {
[SESSION_TTY] = "tty",
[SESSION_X11] = "x11",
static const char* const session_type_table[_SESSION_TYPE_MAX] = {
[SESSION_TTY] = "tty",
[SESSION_X11] = "x11",