summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-12-28 15:22:25 +0000
committerDaniel Stone <daniels@collabora.com>2017-12-28 19:43:20 +0000
commit07d7a9968d9bf258794964584f68777686c90748 (patch)
tree1f82ca3f6b65c7d21621a99bd65a50364d7d0213
parent69fab4fffcab68e355a5c181641cee5a4ead769f (diff)
downloadwayland-07d7a9968d9bf258794964584f68777686c90748.tar.gz
client: Add WL_MAP_ENTRY_ZOMBIE flag
Add a new map entry flag to indicate that the object received is valid, but a zombie. Previously this relied on a fixed object pointer, but future patches in this series will have map entries returning either NULL, or a different structure type entirely, for zombie objects. wl_object_is_zombie() now solely uses the new flag to determine whether or not the object is a zombie. [daniels: Extracted from Derek's bespoke-zombie patch as an intermediate step.] Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
-rw-r--r--src/connection.c13
-rw-r--r--src/wayland-client.c14
-rw-r--r--src/wayland-private.h3
3 files changed, 21 insertions, 9 deletions
diff --git a/src/connection.c b/src/connection.c
index 2e234ea..426be57 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -834,9 +834,18 @@ wl_connection_demarshal(struct wl_connection *connection,
bool
wl_object_is_zombie(struct wl_map *map, uint32_t id)
{
- struct wl_object *object = wl_map_lookup(map, id);
+ uint32_t flags;
- return (object == WL_ZOMBIE_OBJECT);
+ /* Zombie objects only exist on the client side. */
+ if (map->side == WL_MAP_SERVER_SIDE)
+ return false;
+
+ /* Zombie objects can only have been created by the client. */
+ if (id >= WL_SERVER_ID_START)
+ return false;
+
+ flags = wl_map_lookup_flags(map, id);
+ return !!(flags & WL_MAP_ENTRY_ZOMBIE);
}
int
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 126dd90..8fc5634 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -405,15 +405,17 @@ wl_proxy_create_for_id(struct wl_proxy *factory,
static void
proxy_destroy(struct wl_proxy *proxy)
{
- if (proxy->flags & WL_PROXY_FLAG_ID_DELETED)
+ if (proxy->flags & WL_PROXY_FLAG_ID_DELETED) {
wl_map_remove(&proxy->display->objects, proxy->object.id);
- else if (proxy->object.id < WL_SERVER_ID_START)
- wl_map_insert_at(&proxy->display->objects, 0,
- proxy->object.id, WL_ZOMBIE_OBJECT);
- else
+ } else if (proxy->object.id < WL_SERVER_ID_START) {
+ wl_map_insert_at(&proxy->display->objects,
+ WL_MAP_ENTRY_ZOMBIE,
+ proxy->object.id,
+ WL_ZOMBIE_OBJECT);
+ } else {
wl_map_insert_at(&proxy->display->objects, 0,
proxy->object.id, NULL);
-
+ }
proxy->flags |= WL_PROXY_FLAG_DESTROYED;
diff --git a/src/wayland-private.h b/src/wayland-private.h
index c82b1f3..b0d129f 100644
--- a/src/wayland-private.h
+++ b/src/wayland-private.h
@@ -69,7 +69,8 @@ wl_interface_equal(const struct wl_interface *iface1,
* flags. If more flags are ever added, the implementation of wl_map will have
* to change to allow for new flags */
enum wl_map_entry_flags {
- WL_MAP_ENTRY_LEGACY = (1 << 0)
+ WL_MAP_ENTRY_LEGACY = (1 << 0), /* Server side only */
+ WL_MAP_ENTRY_ZOMBIE = (1 << 0) /* Client side only */
};
struct wl_map {