summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2020-07-10 12:57:55 +0200
committerWim Taymans <wtaymans@redhat.com>2020-07-10 12:57:55 +0200
commit5cd495c93ccacacb075e1a2d95ca97ec4161d043 (patch)
treedc3ff65393737d52060a7125574419bea39c3d26 /src/modules
parent0430e7b8dc8596d602993145f242269944f36678 (diff)
client-node: free old mapping only after importing the new
Keep the old mapping around until we manage to successfully import the new mapping.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/module-client-node/client-node.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c
index 3c77df0a..e91669f5 100644
--- a/src/modules/module-client-node/client-node.c
+++ b/src/modules/module-client-node/client-node.c
@@ -362,15 +362,14 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
{
struct node *this = object;
struct impl *impl = this->impl;
- struct pw_memmap *mm;
+ struct pw_memmap *mm, *old;
uint32_t memid, mem_offset, mem_size;
uint32_t tag[5] = { impl->node_id, id, };
if (impl->this.flags & 1)
return 0;
- if ((mm = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag))) != NULL)
- pw_memmap_free(mm);
+ old = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag));
if (data) {
mm = pw_mempool_import_map(this->client->pool,
@@ -386,6 +385,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
memid = SPA_ID_INVALID;
mem_offset = mem_size = 0;
}
+ if (old != NULL)
+ pw_memmap_free(old);
if (this->resource == NULL)
return data == NULL ? 0 : -EIO;
@@ -674,7 +675,7 @@ static int do_port_set_io(struct impl *impl,
struct port *port;
struct mix *mix;
uint32_t tag[5] = { impl->node_id, direction, port_id, mix_id, id };
- struct pw_memmap *mm;
+ struct pw_memmap *mm, *old;
pw_log_debug(NAME " %p: %s port %d.%d set io %p %zd", this,
direction == SPA_DIRECTION_INPUT ? "input" : "output",
@@ -688,8 +689,7 @@ static int do_port_set_io(struct impl *impl,
if ((mix = find_mix(port, mix_id)) == NULL || !mix->valid)
return -EINVAL;
- if ((mm = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag))) != NULL)
- pw_memmap_free(mm);
+ old = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag));
if (data) {
mm = pw_mempool_import_map(this->client->pool,
@@ -705,6 +705,8 @@ static int do_port_set_io(struct impl *impl,
memid = SPA_ID_INVALID;
mem_offset = mem_size = 0;
}
+ if (old != NULL)
+ pw_memmap_free(old);
if (this->resource == NULL)
return data == NULL ? 0 : -EIO;