Commit 41ac7386 authored by Olivier Crête's avatar Olivier Crête Committed by Olivier Crête

agent: Hold ref while doing async close

It's possible that the callback will be called synchronously during the
close function, in this case, we need to be ready to the last reference
to the agent to be dropped in this callback.

This fix was suggested by Fabrice Bellet

Fixes #153
parent 526eec8b
...@@ -7374,11 +7374,16 @@ nice_agent_close_async (NiceAgent *agent, GAsyncReadyCallback callback, ...@@ -7374,11 +7374,16 @@ nice_agent_close_async (NiceAgent *agent, GAsyncReadyCallback callback,
task = g_task_new (agent, NULL, callback, callback_data); task = g_task_new (agent, NULL, callback, callback_data);
g_task_set_source_tag (task, nice_agent_close_async); g_task_set_source_tag (task, nice_agent_close_async);
/* Hold an extra ref here in case the application releases the last ref
* during the callback.
*/
g_object_ref (agent);
agent_lock (agent); agent_lock (agent);
refresh_prune_agent_async (agent, on_agent_refreshes_pruned, task); refresh_prune_agent_async (agent, on_agent_refreshes_pruned, task);
agent_unlock (agent); agent_unlock (agent);
g_object_unref (agent);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment