1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
From dc09ce85f00b3a790e2817888067c3826280dd8e Mon Sep 17 00:00:00 2001
From: Weng Xuetian <wengxt@gmail.com>
Date: Sat, 16 Apr 2022 00:01:12 -0700
Subject: [PATCH] Fix race in wp_drm_lease_v1.
Basically this is a well known issue in wayland for globals. If bind
comes after destroyed, it will raise a invalid global error. The common
practice is to delay the destroy of global. Similar technique is also
applied to wl_output.
CCBUG: 452435
(cherry picked from commit cdc9dcfb0a1f0445c46ee2cefa114329a2408555)
---
src/server/drmleasedevice_v1_interface.cpp | 14 +++++---------
src/server/drmleasedevice_v1_interface_p.h | 2 +-
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/server/drmleasedevice_v1_interface.cpp b/src/server/drmleasedevice_v1_interface.cpp
index bffd22cd..7e338022 100644
--- a/src/server/drmleasedevice_v1_interface.cpp
+++ b/src/server/drmleasedevice_v1_interface.cpp
@@ -84,10 +84,6 @@ void DrmLeaseDeviceV1InterfacePrivate::remove()
request->connectors.clear();
}
globalRemove();
- removed = true;
- if (resourceMap().isEmpty()) {
- delete this;
- }
}
void DrmLeaseDeviceV1InterfacePrivate::registerConnector(DrmLeaseConnectorV1Interface *connector)
@@ -144,6 +140,9 @@ void DrmLeaseDeviceV1InterfacePrivate::wp_drm_lease_device_v1_release(Resource *
void DrmLeaseDeviceV1InterfacePrivate::wp_drm_lease_device_v1_bind_resource(Resource *resource)
{
+ if (isGlobalRemoved()) {
+ return;
+ }
if (!hasDrmMaster) {
pendingFds << resource->handle;
return;
@@ -161,12 +160,9 @@ void DrmLeaseDeviceV1InterfacePrivate::wp_drm_lease_device_v1_bind_resource(Reso
}
}
-void DrmLeaseDeviceV1InterfacePrivate::wp_drm_lease_device_v1_destroy_resource(Resource *resource)
+void DrmLeaseDeviceV1InterfacePrivate::wp_drm_lease_device_v1_destroy_global()
{
- Q_UNUSED(resource)
- if (removed && resourceMap().isEmpty()) {
- delete this;
- }
+ delete this;
}
diff --git a/src/server/drmleasedevice_v1_interface_p.h b/src/server/drmleasedevice_v1_interface_p.h
index 4bef36e4..085aac85 100644
--- a/src/server/drmleasedevice_v1_interface_p.h
+++ b/src/server/drmleasedevice_v1_interface_p.h
@@ -44,7 +44,7 @@ protected:
void wp_drm_lease_device_v1_create_lease_request(Resource *resource, uint32_t id) override;
void wp_drm_lease_device_v1_release(Resource *resource) override;
void wp_drm_lease_device_v1_bind_resource(Resource *resource) override;
- void wp_drm_lease_device_v1_destroy_resource(Resource *resource) override;
+ void wp_drm_lease_device_v1_destroy_global() override;
};
class DrmLeaseConnectorV1InterfacePrivate : public QObject, public QtWaylandServer::wp_drm_lease_connector_v1
--
GitLab
|