Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend/rs: delay client cleanup #772

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ allow = [
# Google categorizes the license under "notice" which means it can be used (with some exceptions like
# notices or advertising clauses): https://opensource.google/documentation/reference/thirdparty/licenses#notice
"Unicode-DFS-2016",
# Unicode-DFS-2016 has been superseded by Unicode V3
"Unicode-3.0",
]
4 changes: 4 additions & 0 deletions wayland-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bugfixes

- backend/rs: Prevent a potential deadlock during client cleanup

## 0.3.7 -- 2024-09-04

### Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn print_send_message<Id: Display, Fd: AsRawFd>(

pub(crate) struct DisplaySlice<'a, D>(pub &'a [D]);

impl<'a, D: Display> Display for DisplaySlice<'a, D> {
impl<D: Display> Display for DisplaySlice<'_, D> {
#[cfg_attr(coverage, coverage(off))]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut it = self.0.iter();
Expand Down
4 changes: 2 additions & 2 deletions wayland-backend/src/rs/server_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,15 +720,15 @@ impl<D> ClientStore<D> {
pub(crate) fn cleanup(
&mut self,
pending_destructors: &mut Vec<PendingDestructor<D>>,
) -> SmallVec<[ClientId; 1]> {
) -> SmallVec<[Client<D>; 1]> {
let mut cleaned = SmallVec::new();
for place in &mut self.clients {
if place.as_ref().map(|client| client.killed).unwrap_or(false) {
// Remove the client from the store and flush it one last time before dropping it
let mut client = place.take().unwrap();
client.queue_all_destructors(pending_destructors);
let _ = client.flush();
cleaned.push(ClientId { id: client.id });
cleaned.push(client);
}
}
cleaned
Expand Down
1 change: 1 addition & 0 deletions wayland-backend/src/rs/server_impl/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl<D> State<D> {
ObjectId { id: object_id },
);
}
std::mem::drop(dead_clients);
}
}

Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/rs/server_impl/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<D> Registry<D> {
Some((target_global.interface, target_global.id.clone(), target_global.handler.clone()))
}

pub(crate) fn cleanup(&mut self, dead_clients: &[ClientId]) {
pub(crate) fn cleanup(&mut self, dead_clients: &[Client<D>]) {
self.known_registries
.retain(|obj_id| !dead_clients.iter().any(|cid| cid.id == obj_id.client_id))
}
Expand Down
2 changes: 1 addition & 1 deletion wayland-client/src/event_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ impl<State: 'static> QueueHandle<State> {
}
}

impl<'a, State> Drop for QueueFreezeGuard<'a, State> {
impl<State> Drop for QueueFreezeGuard<'_, State> {
fn drop(&mut self) {
let mut lock = self.qh.inner.lock().unwrap();
lock.freeze_count -= 1;
Expand Down
2 changes: 1 addition & 1 deletion wayland-server/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub struct DataInit<'a, D: 'static> {
pub(crate) error: &'a mut Option<(u32, String)>,
}

impl<'a, D> DataInit<'a, D> {
impl<D> DataInit<'_, D> {
/// Initialize an object by assigning it its user-data
pub fn init<I: Resource + 'static, U: Send + Sync + 'static>(
&mut self,
Expand Down
3 changes: 3 additions & 0 deletions wayland-sys/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ pub mod signal {
// Safety: the signal pointer is valid
unsafe {
list_for_each!(l, &mut (*signal).listener_list as *mut wl_list, wl_listener, link, {
// nightly only lint
#[allow(unknown_lints)]
#[allow(unpredictable_function_pointer_comparisons)]
if (*l).notify == notify {
return l;
}
Expand Down
Loading