chiark / gitweb /
shared: switch our hash table implementation over to SipHash
[elogind.git] / src / login / logind-session.c
index cd87088456782b07d2b72756ca83a882d03277f4..dc4b3e1621f033a8561e2d76fe345c88905b4c3c 100644 (file)
 #include "bus-error.h"
 #include "logind-session.h"
 
-static unsigned devt_hash_func(const void *p) {
+static unsigned long devt_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
         uint64_t u = *(const dev_t*)p;
 
-        return uint64_hash_func(&u);
+        return uint64_hash_func(&u, hash_key);
 }
 
 static int devt_compare_func(const void *_a, const void *_b) {
@@ -79,7 +79,7 @@ Session* session_new(Manager *m, const char *id) {
                 return NULL;
         }
 
-        s->id = path_get_file_name(s->state_file);
+        s->id = basename(s->state_file);
 
         if (hashmap_put(m->sessions, s->id, s) < 0) {
                 hashmap_free(s->devices);
@@ -334,21 +334,21 @@ int session_load(Session *s) {
                         s->remote = k;
         }
 
+        if (vtnr)
+                safe_atou(vtnr, &s->vtnr);
+
         if (seat && !s->seat) {
                 Seat *o;
 
                 o = hashmap_get(s->manager->seats, seat);
                 if (o)
-                        seat_attach_session(o, s);
+                        r = seat_attach_session(o, s);
+                if (!o || r < 0)
+                        log_error("Cannot attach session %s to seat %s", s->id, seat);
         }
 
-        if (vtnr && s->seat && seat_has_vts(s->seat)) {
-                unsigned int v;
-
-                k = safe_atou(vtnr, &v);
-                if (k >= 0 && v >= 1)
-                        s->vtnr = v;
-        }
+        if (!s->seat || !seat_has_vts(s->seat))
+                s->vtnr = 0;
 
         if (leader) {
                 k = parse_pid(leader, &s->leader);
@@ -954,9 +954,6 @@ void session_add_to_gc_queue(Session *s) {
 SessionState session_get_state(Session *s) {
         assert(s);
 
-        if (s->closing)
-                return SESSION_CLOSING;
-
         if (s->scope_job)
                 return SESSION_OPENING;