[PATCH wayland v3 06/10] util: Pass flags to map iterators
Derek Foreman
derekf at osg.samsung.com
Wed Dec 6 17:22:21 UTC 2017
On the client side we're going to need to know if an object from the
map is a zombie before we attempt to dereference it, so we need to
pass this to the iterator.
Reviewed-by: Daniel Stone <daniels at collabora.com>
Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
src/wayland-private.h | 3 ++-
src/wayland-server.c | 21 +++++++++++++++------
src/wayland-util.c | 2 +-
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/wayland-private.h b/src/wayland-private.h
index 434cb04..93cec6b 100644
--- a/src/wayland-private.h
+++ b/src/wayland-private.h
@@ -80,7 +80,8 @@ struct wl_map {
};
typedef enum wl_iterator_result (*wl_iterator_func_t)(void *element,
- void *data);
+ void *data,
+ uint32_t flags);
void
wl_map_init(struct wl_map *map, uint32_t side);
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 61e0315..9b1007b 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -658,11 +658,9 @@ resource_is_deprecated(struct wl_resource *resource)
}
static enum wl_iterator_result
-destroy_resource(void *element, void *data)
+_destroy_resource(void *element, void *data, uint32_t flags)
{
struct wl_resource *resource = element;
- struct wl_client *client = resource->client;
- uint32_t flags;
wl_signal_emit(&resource->deprecated_destroy_signal, resource);
/* Don't emit the new signal for deprecated resources, as that would
@@ -670,7 +668,6 @@ destroy_resource(void *element, void *data)
if (!resource_is_deprecated(resource))
wl_priv_signal_emit(&resource->destroy_signal, resource);
- flags = wl_map_lookup_flags(&client->objects, resource->object.id);
if (resource->destroy)
resource->destroy(resource);
@@ -680,6 +677,18 @@ destroy_resource(void *element, void *data)
return WL_ITERATOR_CONTINUE;
}
+static enum wl_iterator_result
+destroy_resource(void *element, void *data)
+{
+ struct wl_resource *resource = element;
+ struct wl_client *client = resource->client;
+ uint32_t flags;
+
+ flags = wl_map_lookup_flags(&client->objects, resource->object.id);
+
+ return _destroy_resource(element, data, flags);
+}
+
WL_EXPORT void
wl_resource_destroy(struct wl_resource *resource)
{
@@ -829,7 +838,7 @@ wl_client_destroy(struct wl_client *client)
wl_priv_signal_emit(&client->destroy_signal, client);
wl_client_flush(client);
- wl_map_for_each(&client->objects, destroy_resource, &serial);
+ wl_map_for_each(&client->objects, _destroy_resource, &serial);
wl_map_release(&client->objects);
wl_event_source_remove(client->source);
close(wl_connection_destroy(client->connection));
@@ -1839,7 +1848,7 @@ struct wl_resource_iterator_context {
};
static enum wl_iterator_result
-resource_iterator_helper(void *res, void *user_data)
+resource_iterator_helper(void *res, void *user_data, uint32_t flags)
{
struct wl_resource_iterator_context *context = user_data;
struct wl_resource *resource = res;
diff --git a/src/wayland-util.c b/src/wayland-util.c
index cab7fc5..ce387f4 100644
--- a/src/wayland-util.c
+++ b/src/wayland-util.c
@@ -371,7 +371,7 @@ for_each_helper(struct wl_array *entries, wl_iterator_func_t func, void *data)
for (p = start; p < end; p++)
if (p->data && !map_entry_is_free(*p)) {
- ret = func(map_entry_get_data(*p), data);
+ ret = func(map_entry_get_data(*p), data, map_entry_get_flags(*p));
if (ret != WL_ITERATOR_CONTINUE)
break;
}
--
2.15.0
More information about the wayland-devel
mailing list