[Pkg-telepathy-commits] [libnice] 154/265: component: Keep its own context at all times
Simon McVittie
smcv at debian.org
Wed May 14 12:05:03 UTC 2014
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian
in repository libnice.
commit e0a7b9343237f6cf31b96082c6c6939526aabf5f
Author: Olivier Crête <olivier.crete at collabora.com>
Date: Mon Feb 24 23:00:33 2014 -0500
component: Keep its own context at all times
Don't re-create it.
---
agent/component.c | 17 +++++++++++------
agent/component.h | 4 +++-
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/agent/component.c b/agent/component.c
index 1ddd586..d22816e 100644
--- a/agent/component.c
+++ b/agent/component.c
@@ -125,6 +125,9 @@ component_new (guint id, NiceAgent *agent, Stream *stream)
g_queue_init (&component->pending_io_messages);
component->io_callback_id = 0;
+ component->own_ctx = g_main_context_new ();
+ component->ctx = g_main_context_ref (component->own_ctx);
+
/* Start off with a fresh main context and all I/O paused. This
* will be updated when nice_agent_attach_recv() or nice_agent_recv_messages()
* are called. */
@@ -207,6 +210,8 @@ component_free (Component *cmp)
cmp->ctx = NULL;
}
+ g_main_context_unref (cmp->own_ctx);
+
while ((vec = g_queue_pop_head (&cmp->queued_tcp_packets)) != NULL) {
g_free ((gpointer) vec->buffer);
g_slice_free (GOutputVector, vec);
@@ -540,25 +545,25 @@ component_free_socket_sources (Component *component)
GMainContext *
component_dup_io_context (Component *component)
{
- return g_main_context_ref (component->ctx);
+ return g_main_context_ref (component->own_ctx);
}
-/* If @context is %NULL, a fresh context is used, so component->ctx is always
+/* If @context is %NULL, it's own context is used, so component->ctx is always
* guaranteed to be non-%NULL. */
void
component_set_io_context (Component *component, GMainContext *context)
{
g_mutex_lock (&component->io_mutex);
- if (component->ctx != context || component->ctx == NULL) {
+ if (component->ctx != context) {
if (context == NULL)
- context = g_main_context_new ();
+ context = g_main_context_ref (component->own_ctx);
else
g_main_context_ref (context);
component_detach_all_sockets (component);
- if (component->ctx != NULL)
- g_main_context_unref (component->ctx);
+ g_main_context_unref (component->ctx);
+
component->ctx = context;
component_reattach_all_sockets (component);
}
diff --git a/agent/component.h b/agent/component.h
index 5c01158..6433a85 100644
--- a/agent/component.h
+++ b/agent/component.h
@@ -171,8 +171,10 @@ struct _Component
IOCallbackData */
guint io_callback_id; /* GSource ID of the I/O callback */
- GMainContext *ctx; /**< context for GSources for this
+ GMainContext *own_ctx; /**< own context for GSources for this
component */
+ GMainContext *ctx; /**< context for GSources for this
+ component (possibly set from the app) */
NiceInputMessage *recv_messages; /**< unowned messages for receiving into */
guint n_recv_messages; /**< length of recv_messages */
NiceInputMessageIter recv_messages_iter; /**< current write position in
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git
More information about the Pkg-telepathy-commits
mailing list