Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
e0a7b934
Commit
e0a7b934
authored
Feb 24, 2014
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
component: Keep its own context at all times
Don't re-create it.
parent
27e653ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
agent/component.c
agent/component.c
+11
-6
agent/component.h
agent/component.h
+3
-1
No files found.
agent/component.c
View file @
e0a7b934
...
@@ -125,6 +125,9 @@ component_new (guint id, NiceAgent *agent, Stream *stream)
...
@@ -125,6 +125,9 @@ component_new (guint id, NiceAgent *agent, Stream *stream)
g_queue_init
(
&
component
->
pending_io_messages
);
g_queue_init
(
&
component
->
pending_io_messages
);
component
->
io_callback_id
=
0
;
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
/* 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()
* will be updated when nice_agent_attach_recv() or nice_agent_recv_messages()
* are called. */
* are called. */
...
@@ -207,6 +210,8 @@ component_free (Component *cmp)
...
@@ -207,6 +210,8 @@ component_free (Component *cmp)
cmp
->
ctx
=
NULL
;
cmp
->
ctx
=
NULL
;
}
}
g_main_context_unref
(
cmp
->
own_ctx
);
while
((
vec
=
g_queue_pop_head
(
&
cmp
->
queued_tcp_packets
))
!=
NULL
)
{
while
((
vec
=
g_queue_pop_head
(
&
cmp
->
queued_tcp_packets
))
!=
NULL
)
{
g_free
((
gpointer
)
vec
->
buffer
);
g_free
((
gpointer
)
vec
->
buffer
);
g_slice_free
(
GOutputVector
,
vec
);
g_slice_free
(
GOutputVector
,
vec
);
...
@@ -540,25 +545,25 @@ component_free_socket_sources (Component *component)
...
@@ -540,25 +545,25 @@ component_free_socket_sources (Component *component)
GMainContext
*
GMainContext
*
component_dup_io_context
(
Component
*
component
)
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. */
* guaranteed to be non-%NULL. */
void
void
component_set_io_context
(
Component
*
component
,
GMainContext
*
context
)
component_set_io_context
(
Component
*
component
,
GMainContext
*
context
)
{
{
g_mutex_lock
(
&
component
->
io_mutex
);
g_mutex_lock
(
&
component
->
io_mutex
);
if
(
component
->
ctx
!=
context
||
component
->
ctx
==
NULL
)
{
if
(
component
->
ctx
!=
context
)
{
if
(
context
==
NULL
)
if
(
context
==
NULL
)
context
=
g_main_context_
new
(
);
context
=
g_main_context_
ref
(
component
->
own_ctx
);
else
else
g_main_context_ref
(
context
);
g_main_context_ref
(
context
);
component_detach_all_sockets
(
component
);
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
->
ctx
=
context
;
component_reattach_all_sockets
(
component
);
component_reattach_all_sockets
(
component
);
}
}
...
...
agent/component.h
View file @
e0a7b934
...
@@ -171,8 +171,10 @@ struct _Component
...
@@ -171,8 +171,10 @@ struct _Component
IOCallbackData */
IOCallbackData */
guint
io_callback_id
;
/* GSource ID of the I/O callback */
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 */
component */
GMainContext
*
ctx
;
/**< context for GSources for this
component (possibly set from the app) */
NiceInputMessage
*
recv_messages
;
/**< unowned messages for receiving into */
NiceInputMessage
*
recv_messages
;
/**< unowned messages for receiving into */
guint
n_recv_messages
;
/**< length of recv_messages */
guint
n_recv_messages
;
/**< length of recv_messages */
NiceInputMessageIter
recv_messages_iter
;
/**< current write position in
NiceInputMessageIter
recv_messages_iter
;
/**< current write position in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment