diff options
Diffstat (limited to 'seatd')
-rw-r--r-- | seatd/client.c | 10 | ||||
-rw-r--r-- | seatd/seat.c | 7 | ||||
-rw-r--r-- | seatd/server.c | 3 |
3 files changed, 6 insertions, 14 deletions
diff --git a/seatd/client.c b/seatd/client.c index fcb238d..5cacae7 100644 --- a/seatd/client.c +++ b/seatd/client.c @@ -70,6 +70,7 @@ struct client *client_create(struct server *server, int client_fd) { client->server = server; client->connection.fd = client_fd; linked_list_init(&client->devices); + linked_list_insert(&server->idle_clients, &client->link); return client; } @@ -80,14 +81,9 @@ void client_destroy(struct client *client) { close(client->connection.fd); client->connection.fd = -1; } + linked_list_remove(&client->link); if (client->seat != NULL) { - // This should also close and remove all devices. This unlinks - // the client. seat_remove_client(client); - } else { - // If we are not a member of a seat, we will be on the idle - // clients list, so unlink the client manually. - linked_list_remove(&client->link); } if (client->event_source != NULL) { event_source_fd_destroy(client->event_source); @@ -149,6 +145,7 @@ static int handle_open_seat(struct client *client) { log_errorf("unable to add client to target seat: %s", strerror(errno)); return -1; } + linked_list_insert(&seat->clients, &client->link); size_t seat_name_len = strlen(seat_name); @@ -177,6 +174,7 @@ static int handle_close_seat(struct client *client) { return -1; } + linked_list_remove(&client->link); if (seat_remove_client(client) == -1) { log_error("unable to remove client from seat"); return -1; diff --git a/seatd/seat.c b/seatd/seat.c index 66b623d..b530a36 100644 --- a/seatd/seat.c +++ b/seatd/seat.c @@ -149,9 +149,8 @@ int seat_add_client(struct seat *seat, struct client *client) { log_debugf("registered client %p as session %d", (void *)client, client->session); client->seat = seat; - - linked_list_insert(&seat->clients, &client->link); log_debug("added client"); + return 0; } @@ -160,10 +159,6 @@ int seat_remove_client(struct client *client) { assert(client->seat); struct seat *seat = client->seat; - - // We must first remove the client to avoid reactivation - linked_list_remove(&client->link); - if (seat->next_client == client) { seat->next_client = NULL; } diff --git a/seatd/server.c b/seatd/server.c index acb366e..3ca73b3 100644 --- a/seatd/server.c +++ b/seatd/server.c @@ -132,13 +132,12 @@ int server_add_client(struct server *server, int fd) { client->event_source = poller_add_fd(&server->poller, fd, EVENT_READABLE, client_handle_connection, client); if (client->event_source == NULL) { - client_destroy(client); log_errorf("could not add client socket to poller: %s", strerror(errno)); + client_destroy(client); return -1; } log_infof("new client connected (pid: %d, uid: %d, gid: %d)", client->pid, client->uid, client->gid); - linked_list_insert(&server->idle_clients, &client->link); return 0; } |