client-node: safely remove source

Remove the source from the data_loop with invoke to make sure it
really is removed before we destroy the node.

Based on patch by David Svensson Fors <davidsf at axis.com>
This commit is contained in:
Wim Taymans 2018-03-14 14:52:22 +01:00
parent 638916e065
commit 153bf51ef1

View file

@ -1162,6 +1162,18 @@ static int node_clear(struct node *this)
return 0; return 0;
} }
static int do_remove_source(struct spa_loop *loop,
bool async,
uint32_t seq,
const void *data,
size_t size,
void *user_data)
{
struct spa_source *source = user_data;
spa_loop_remove_source(loop, source);
return 0;
}
static void client_node_resource_destroy(void *data) static void client_node_resource_destroy(void *data)
{ {
struct impl *impl = data; struct impl *impl = data;
@ -1172,13 +1184,18 @@ static void client_node_resource_destroy(void *data)
impl->node.resource = this->resource = NULL; impl->node.resource = this->resource = NULL;
if (node->data_source.fd != -1) if (node->data_source.fd != -1) {
spa_loop_remove_source(node->data_loop, &node->data_source); spa_loop_invoke(node->data_loop,
do_remove_source,
SPA_ID_INVALID,
NULL,
0,
true,
&node->data_source);
}
pw_node_destroy(this->node); pw_node_destroy(this->node);
} }
static void node_initialized(void *data) static void node_initialized(void *data)
{ {
struct impl *impl = data; struct impl *impl = data;