summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-08-19 17:07:14 -0400
committerKristian Høgsberg <krh@bitplanet.net>2011-08-19 17:07:14 -0400
commitf4144b50125705cdb2489d2c246206540cc038af (patch)
treed330503770b8218084ab09a4b13a8742c1bba837 /src
parentAlways allocate a new wl_resource when binding an object (diff)
downloadwayland-f4144b50125705cdb2489d2c246206540cc038af.tar
wayland-f4144b50125705cdb2489d2c246206540cc038af.tar.gz
wayland-f4144b50125705cdb2489d2c246206540cc038af.tar.bz2
wayland-f4144b50125705cdb2489d2c246206540cc038af.tar.lz
wayland-f4144b50125705cdb2489d2c246206540cc038af.tar.xz
wayland-f4144b50125705cdb2489d2c246206540cc038af.tar.zst
wayland-f4144b50125705cdb2489d2c246206540cc038af.zip
Destroy client resource by walking client hash table
All resources are now in the client hash table and we can clean up just by walking the hash.
Diffstat (limited to 'src')
-rw-r--r--src/wayland-server.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 0f15afd..d9b2593 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -58,7 +58,6 @@ struct wl_client {
struct wl_event_source *source;
struct wl_display *display;
struct wl_resource *display_resource;
- struct wl_list resource_list;
uint32_t id_count;
uint32_t mask;
struct wl_list link;
@@ -286,9 +285,6 @@ wl_client_create(struct wl_display *display, int fd)
wl_list_insert(display->client_list.prev, &client->link);
- wl_list_init(&client->resource_list);
-
-
return client;
}
@@ -303,9 +299,7 @@ wl_client_add_resource(struct wl_client *client,
resource->client = client;
wl_list_init(&resource->destroy_listener_list);
-
wl_hash_table_insert(client->objects, resource->object.id, resource);
- wl_list_insert(client->resource_list.prev, &resource->link);
}
WL_EXPORT void
@@ -315,31 +309,37 @@ wl_client_post_no_memory(struct wl_client *client)
WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
}
+static void
+destroy_resource(void *element, void *data)
+{
+ struct wl_resource *resource = element;
+ struct wl_listener *l, *next;
+ uint32_t *time = data;
+
+ wl_list_for_each_safe(l, next, &resource->destroy_listener_list, link)
+ l->func(l, resource, *time);
+
+ if (resource->destroy)
+ resource->destroy(resource);
+}
+
WL_EXPORT void
wl_resource_destroy(struct wl_resource *resource, uint32_t time)
{
struct wl_client *client = resource->client;
- struct wl_listener *l, *next;
- wl_list_for_each_safe(l, next, &resource->destroy_listener_list, link)
- l->func(l, resource, time);
-
- wl_list_remove(&resource->link);
- if (resource->object.id > 0)
- wl_hash_table_remove(client->objects, resource->object.id);
- resource->destroy(resource);
+ destroy_resource(resource, &time);
+ wl_hash_table_remove(client->objects, resource->object.id);
}
WL_EXPORT void
wl_client_destroy(struct wl_client *client)
{
- struct wl_resource *resource, *tmp;
+ uint32_t time = 0;
printf("disconnect from client %p\n", client);
- wl_list_for_each_safe(resource, tmp, &client->resource_list, link)
- wl_resource_destroy(resource, 0);
-
+ wl_hash_table_for_each(client->objects, destroy_resource, &time);
wl_hash_table_destroy(client->objects);
wl_event_source_remove(client->source);
wl_connection_destroy(client->connection);
@@ -886,8 +886,6 @@ compositor_bind(struct wl_client *client,
WL_COMPOSITOR_TOKEN_VISUAL,
compositor->rgb_visual.name,
WL_COMPOSITOR_VISUAL_XRGB32);
-
- wl_list_insert(client->resource_list.prev, &resource->link);
}
static void