aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-12-28 15:15:46 +0000
committerDaniel Stone <daniels@collabora.com>2017-12-28 15:16:37 +0000
commit69fab4fffcab68e355a5c181641cee5a4ead769f (patch)
tree49f125325070f5c4778c870c6400351daa586427
parentutil: Pass flags to map iterators (diff)
downloadwayland-69fab4fffcab68e355a5c181641cee5a4ead769f.tar
wayland-69fab4fffcab68e355a5c181641cee5a4ead769f.tar.gz
wayland-69fab4fffcab68e355a5c181641cee5a4ead769f.tar.bz2
wayland-69fab4fffcab68e355a5c181641cee5a4ead769f.tar.lz
wayland-69fab4fffcab68e355a5c181641cee5a4ead769f.tar.xz
wayland-69fab4fffcab68e355a5c181641cee5a4ead769f.tar.zst
wayland-69fab4fffcab68e355a5c181641cee5a4ead769f.zip
client: Add wl_object_is_zombie() helper function
Add a helper function which determines whether or not an 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.c10
-rw-r--r--src/wayland-client.c4
-rw-r--r--src/wayland-private.h3
3 files changed, 14 insertions, 3 deletions
diff --git a/src/connection.c b/src/connection.c
index e92de79..2e234ea 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -831,6 +831,14 @@ wl_connection_demarshal(struct wl_connection *connection,
return NULL;
}
+bool
+wl_object_is_zombie(struct wl_map *map, uint32_t id)
+{
+ struct wl_object *object = wl_map_lookup(map, id);
+
+ return (object == WL_ZOMBIE_OBJECT);
+}
+
int
wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)
{
@@ -852,7 +860,7 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)
closure->args[i].o = NULL;
object = wl_map_lookup(objects, id);
- if (object == WL_ZOMBIE_OBJECT) {
+ if (wl_object_is_zombie(objects, id)) {
/* references object we've already
* destroyed client side */
object = NULL;
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 795b4e9..126dd90 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -837,7 +837,7 @@ display_handle_delete_id(void *data, struct wl_display *display, uint32_t id)
if (!proxy)
wl_log("error: received delete_id for unknown id (%u)\n", id);
- if (proxy && proxy != WL_ZOMBIE_OBJECT)
+ if (proxy && !wl_object_is_zombie(&display->objects, id))
proxy->flags |= WL_PROXY_FLAG_ID_DELETED;
else
wl_map_remove(&display->objects, id);
@@ -1253,7 +1253,7 @@ queue_event(struct wl_display *display, int len)
return 0;
proxy = wl_map_lookup(&display->objects, id);
- if (!proxy || proxy == WL_ZOMBIE_OBJECT) {
+ if (!proxy || wl_object_is_zombie(&display->objects, id)) {
wl_connection_consume(display->connection, size);
return size;
}
diff --git a/src/wayland-private.h b/src/wayland-private.h
index 93cec6b..c82b1f3 100644
--- a/src/wayland-private.h
+++ b/src/wayland-private.h
@@ -190,6 +190,9 @@ wl_connection_demarshal(struct wl_connection *connection,
struct wl_map *objects,
const struct wl_message *message);
+bool
+wl_object_is_zombie(struct wl_map *map, uint32_t id);
+
int
wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects);