commit ddda681

Michael Forney  ·  2014-02-24 09:11:58 +0000 UTC
parent 330bc84
shm: Fix pool destruction
1 files changed,  +10, -5
+10, -5
 1@@ -58,10 +58,8 @@ struct pool_reference
 2     struct pool * pool;
 3 };
 4 
 5-static void unref_pool(struct wl_resource * resource)
 6+static void unref_pool(struct pool * pool)
 7 {
 8-    struct pool * pool = wl_resource_get_user_data(resource);
 9-
10     if (--pool->references > 0)
11         return;
12 
13@@ -69,12 +67,19 @@ static void unref_pool(struct wl_resource * resource)
14     free(pool);
15 }
16 
17+static void destroy_pool_resource(struct wl_resource * resource)
18+{
19+    struct pool * pool = wl_resource_get_user_data(resource);
20+
21+    unref_pool(pool);
22+}
23+
24 static void handle_buffer_destroy(struct wld_destructor * destructor)
25 {
26     struct pool_reference * reference
27         = CONTAINER_OF(destructor, typeof(*reference), destructor);
28 
29-    unref_pool(reference->pool->resource);
30+    unref_pool(reference->pool);
31 }
32 
33 static inline uint32_t format_shm_to_wld(uint32_t format)
34@@ -191,7 +196,7 @@ static void create_pool(struct wl_client * client,
35     }
36 
37     wl_resource_set_implementation(pool->resource, &shm_pool_implementation,
38-                                   pool, &unref_pool);
39+                                   pool, &destroy_pool_resource);
40     pool->data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
41 
42     if (pool->data == MAP_FAILED)