Skip to content

Commit 086597e

Browse files
cmeisslids1024
authored andcommitted
backend/rs: delay client cleanup
delay client cleanup until the state lock is dropped to prevent potential deadlocks in drop impls of the client state.
1 parent a078c5b commit 086597e

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

wayland-backend/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Bugfixes
6+
7+
- backend/rs: Prevent a potential deadlock during client cleanup
8+
59
## 0.3.7 -- 2024-09-04
610

711
### Bugfixes

wayland-backend/src/rs/server_impl/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,15 +720,15 @@ impl<D> ClientStore<D> {
720720
pub(crate) fn cleanup(
721721
&mut self,
722722
pending_destructors: &mut Vec<PendingDestructor<D>>,
723-
) -> SmallVec<[ClientId; 1]> {
723+
) -> SmallVec<[Client<D>; 1]> {
724724
let mut cleaned = SmallVec::new();
725725
for place in &mut self.clients {
726726
if place.as_ref().map(|client| client.killed).unwrap_or(false) {
727727
// Remove the client from the store and flush it one last time before dropping it
728728
let mut client = place.take().unwrap();
729729
client.queue_all_destructors(pending_destructors);
730730
let _ = client.flush();
731-
cleaned.push(ClientId { id: client.id });
731+
cleaned.push(client);
732732
}
733733
}
734734
cleaned

wayland-backend/src/rs/server_impl/handle.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl<D> State<D> {
5353
ObjectId { id: object_id },
5454
);
5555
}
56+
std::mem::drop(dead_clients);
5657
}
5758
}
5859

wayland-backend/src/rs/server_impl/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<D> Registry<D> {
127127
Some((target_global.interface, target_global.id.clone(), target_global.handler.clone()))
128128
}
129129

130-
pub(crate) fn cleanup(&mut self, dead_clients: &[ClientId]) {
130+
pub(crate) fn cleanup(&mut self, dead_clients: &[Client<D>]) {
131131
self.known_registries
132132
.retain(|obj_id| !dead_clients.iter().any(|cid| cid.id == obj_id.client_id))
133133
}

0 commit comments

Comments
 (0)