diff options
-rw-r--r-- | agent/agent.c | 13 | ||||
-rw-r--r-- | agent/component.c | 5 | ||||
-rw-r--r-- | socket/tcp-bsd.c | 5 |
3 files changed, 17 insertions, 6 deletions
diff --git a/agent/agent.c b/agent/agent.c index 3c66986..7f54f33 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -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; diff --git a/agent/component.c b/agent/component.c index 0c45976..b612154 100644 --- a/agent/component.c +++ b/agent/component.c @@ -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); } diff --git a/socket/tcp-bsd.c b/socket/tcp-bsd.c index c8a5c48..67aeb5e 100644 --- a/socket/tcp-bsd.c +++ b/socket/tcp-bsd.c @@ -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); } |