if (dual_timestamp_is_set(&u->timestamp))
fprintf(f,
- "REALTIME=%llu\n"
- "MONOTONIC=%llu\n",
- (unsigned long long) u->timestamp.realtime,
- (unsigned long long) u->timestamp.monotonic);
+ "REALTIME="USEC_FMT"\n"
+ "MONOTONIC="USEC_FMT"\n",
+ u->timestamp.realtime,
+ u->timestamp.monotonic);
if (u->sessions) {
Session *i;
finish:
if (r < 0)
- log_error("Failed to save user data for %s: %s", u->name, strerror(-r));
+ log_error("Failed to save user data %s: %s", u->state_file, strerror(-r));
return r;
}
if (k < 0)
r = k;
+ u->stopping = true;
+
user_save(u);
return r;
return idle_hint;
}
-static int user_check_linger_file(User *u) {
+int user_check_linger_file(User *u) {
_cleanup_free_ char *cc = NULL;
char *p = NULL;
if (u->service_job && manager_job_is_active(u->manager, u->service_job))
return true;
- if (u->slice && manager_unit_is_active(u->manager, u->slice) != 0)
- return true;
-
- if (u->service && manager_unit_is_active(u->manager, u->service) != 0)
- return true;
-
return false;
}
UserState user_get_state(User *u) {
Session *i;
- bool all_closing = true;
assert(u);
- if (u->closing)
+ if (u->stopping)
return USER_CLOSING;
if (u->slice_job || u->service_job)
return USER_OPENING;
- LIST_FOREACH(sessions_by_user, i, u->sessions) {
- if (session_is_active(i))
- return USER_ACTIVE;
- if (session_get_state(i) != SESSION_CLOSING)
- all_closing = false;
- }
+ if (u->sessions) {
+ bool all_closing = true;
+
+ LIST_FOREACH(sessions_by_user, i, u->sessions) {
+ if (session_is_active(i))
+ return USER_ACTIVE;
+ if (session_get_state(i) != SESSION_CLOSING)
+ all_closing = false;
+ }
- if (u->sessions)
return all_closing ? USER_CLOSING : USER_ONLINE;
+ }
if (user_check_linger_file(u) > 0)
return USER_LINGERING;