aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-29 23:49:22 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-29 23:49:22 +0200
commit5470c481134ab194f32f53fd8d5ba7c916478f74 (patch)
tree431095b7a02714d4eed970a0708dd13326bf4304
parentb7b28f06281efa162e1feaa20324012a0ed59dc4 (diff)
seat: Destroy all clients on teardown
-rw-r--r--include/client.h1
-rw-r--r--seatd/client.c18
-rw-r--r--seatd/seat.c3
3 files changed, 5 insertions, 17 deletions
diff --git a/include/client.h b/include/client.h
index e0d9016..75e4f46 100644
--- a/include/client.h
+++ b/include/client.h
@@ -28,7 +28,6 @@ struct client {
};
struct client *client_create(struct server *server, int client_fd);
-void client_kill(struct client *client);
void client_destroy(struct client *client);
int client_handle_connection(int fd, uint32_t mask, void *data);
diff --git a/seatd/client.c b/seatd/client.c
index 1adc2d9..0991fbb 100644
--- a/seatd/client.c
+++ b/seatd/client.c
@@ -72,19 +72,13 @@ struct client *client_create(struct server *server, int client_fd) {
return client;
}
-void client_kill(struct client *client) {
- assert(client);
- if (client->connection.fd != -1) {
- shutdown(client->connection.fd, SHUT_RDWR);
- };
- if (client->seat != NULL) {
- seat_remove_client(client);
- }
-}
-
void client_destroy(struct client *client) {
assert(client);
client->server = NULL;
+ if (client->connection.fd != -1) {
+ close(client->connection.fd);
+ client->connection.fd = -1;
+ }
if (client->seat != NULL) {
// This should also close and remove all devices
seat_remove_client(client);
@@ -93,10 +87,6 @@ void client_destroy(struct client *client) {
event_source_fd_destroy(client->event_source);
client->event_source = NULL;
}
- if (client->connection.fd != -1) {
- close(client->connection.fd);
- client->connection.fd = -1;
- }
connection_close_fds(&client->connection);
assert(linked_list_empty(&client->devices));
free(client);
diff --git a/seatd/seat.c b/seatd/seat.c
index 40fbb09..fee727c 100644
--- a/seatd/seat.c
+++ b/seatd/seat.c
@@ -39,9 +39,8 @@ void seat_destroy(struct seat *seat) {
assert(seat);
while (!linked_list_empty(&seat->clients)) {
struct client *client = (struct client *)seat->clients.next;
- // This will cause the client to remove itself from the seat
assert(client->seat == seat);
- client_kill(client);
+ client_destroy(client);
}
assert(seat->curttyfd == -1);