Commit 5aa81a86 authored by Olivier Crête's avatar Olivier Crête

Keep a ref on the GMainContext that are attached to

parent a41f0d63
......@@ -2733,10 +2733,18 @@ nice_agent_attach_recv (
ret = TRUE;
component->g_source_io_cb = NULL;
component->data = NULL;
if (component->ctx)
g_main_context_unref (component->ctx);
component->ctx = NULL;
if (func) {
component->g_source_io_cb = func;
component->data = data;
component->ctx = ctx;
if (ctx)
g_main_context_ref (ctx);
priv_attach_stream_component (agent, stream, component);
......@@ -2749,13 +2757,8 @@ nice_agent_attach_recv (
if (component->tcp && component->tcp_data && component->tcp_readable)
pseudo_tcp_socket_readable (component->tcp, component->tcp_data);
} else {
component->g_source_io_cb = NULL;
component->data = NULL;
component->ctx = NULL;
}
done:
agent_unlock();
return ret;
......
......@@ -140,6 +140,11 @@ component_free (Component *cmp)
cmp->tcp_data = NULL;
}
if (cmp->ctx != NULL) {
g_main_context_unref (cmp->ctx);
cmp->ctx = NULL;
}
g_slice_free (Component, cmp);
}
......
......@@ -164,7 +164,7 @@ nice_tcp_bsd_socket_new (NiceAgent *agent, GMainContext *ctx, NiceAddress *addr)
sock->priv = priv = g_slice_new0 (TcpPriv);
priv->agent = agent;
priv->context = ctx;
priv->context = g_main_context_ref (ctx);
priv->server_addr = *addr;
priv->error = FALSE;
......@@ -197,6 +197,9 @@ socket_close (NiceSocket *sock)
g_queue_foreach (&priv->send_queue, (GFunc) free_to_be_sent, NULL);
g_queue_clear (&priv->send_queue);
if (priv->context)
g_main_context_unref (priv->context);
g_slice_free(TcpPriv, sock->priv);
}
......
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