Skip to content

Commit

Permalink
Restore guard semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduerr committed Jun 3, 2024
1 parent ce997b0 commit e17ba0b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions wayland-backend/src/sys/client_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl InnerBackend {
data: Option<Arc<dyn ObjectData>>,
child_spec: Option<(&'static Interface, u32)>,
) -> Result<ObjectId, InvalidId> {
let guard = self.lock_state();
let mut guard = self.lock_state();
// check that the argument list is valid
let message_desc = match id.interface.requests.get(opcode as usize) {
Some(msg) => msg,
Expand Down Expand Up @@ -690,8 +690,7 @@ impl InnerBackend {

// initialize the proxy
let child_id = if let Some((child_interface, _)) = child_spec {
drop(guard);
unsafe { self.manage_object(child_interface, ret, data) }
unsafe { self.manage_object_internal(child_interface, ret, data, &mut guard) }
} else {
Self::null_id()
};
Expand All @@ -717,7 +716,6 @@ impl InnerBackend {
udata.data.destroyed(ObjectId { id: id.clone() });
}

let mut guard = self.lock_state();
guard.known_proxies.remove(&id.ptr);

unsafe {
Expand Down Expand Up @@ -777,7 +775,19 @@ impl InnerBackend {
data: Option<Arc<dyn ObjectData>>,
) -> ObjectId {
let mut guard = self.lock_state();
unsafe { self.manage_object_internal(interface, proxy, data, &mut guard) }
}

/// Start managing a Wayland object.
///
/// Opposed to [`Self::manage_object`], this does not acquire any guards.
unsafe fn manage_object_internal(
&self,
interface: &'static Interface,
proxy: *mut wl_proxy,
data: Option<Arc<dyn ObjectData>>,
guard: &mut MutexGuard<ConnectionState>,
) -> ObjectId {
let alive = Arc::new(AtomicBool::new(true));
let object_id = ObjectId {
id: InnerObjectId {
Expand Down

0 comments on commit e17ba0b

Please sign in to comment.