Commit 675d1d20 authored by Sjoerd Simons's avatar Sjoerd Simons

Remove timeout sources from the right context

parent f543d6b9
......@@ -86,9 +86,9 @@ struct _NiceAgent
NiceRNG *rng; /**< random number generator */
GSList *discovery_list; /**< list of CandidateDiscovery items */
guint discovery_unsched_items; /**< number of discovery items unscheduled */
guint discovery_timer_id; /**< id of discovery timer */
guint conncheck_timer_id; /**< id of discovery timer */
guint keepalive_timer_id; /**< id of keepalive timer */
GSource *discovery_timer_source; /**< source of discovery timer */
GSource *conncheck_timer_source; /**< source of conncheck timer */
GSource *keepalive_timer_source; /**< source of keepalive timer */
guint64 tie_breaker; /**< tie breaker (ICE sect 5.2
"Determining Role" ID-19) */
GStaticRecMutex mutex; /* Mutex used for thread-safe lib */
......@@ -133,7 +133,7 @@ void agent_signal_initial_binding_request_received (NiceAgent *agent, Stream *st
guint64 agent_candidate_pair_priority (NiceAgent *agent, NiceCandidate *local, NiceCandidate *remote);
guint agent_timeout_add_with_context (NiceAgent *agent, guint interval, GSourceFunc function, gpointer data);
GSource *agent_timeout_add_with_context (NiceAgent *agent, guint interval, GSourceFunc function, gpointer data);
void priv_attach_stream_component_socket (NiceAgent *agent,
Stream *stream,
......
......@@ -367,9 +367,9 @@ nice_agent_init (NiceAgent *agent)
agent->discovery_list = NULL;
agent->discovery_unsched_items = 0;
agent->discovery_timer_id = 0;
agent->conncheck_timer_id = 0;
agent->keepalive_timer_id = 0;
agent->discovery_timer_source = NULL;
agent->conncheck_timer_source = NULL;
agent->keepalive_timer_source = NULL;
agent->compatibility = NICE_COMPATIBILITY_DRAFT19;
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
......@@ -909,9 +909,10 @@ nice_agent_gather_candidates (
static void priv_remove_keepalive_timer (NiceAgent *agent)
{
if (agent->keepalive_timer_id) {
g_source_remove (agent->keepalive_timer_id),
agent->keepalive_timer_id = 0;
if (agent->keepalive_timer_source != NULL) {
g_source_destroy (agent->keepalive_timer_source);
g_source_unref (agent->keepalive_timer_source);
agent->keepalive_timer_source = NULL;
}
}
......@@ -2042,7 +2043,7 @@ nice_agent_set_selected_pair (
}
guint agent_timeout_add_with_context (NiceAgent *agent, guint interval,
GSource* agent_timeout_add_with_context (NiceAgent *agent, guint interval,
GSourceFunc function, gpointer data)
{
GSource *source;
......@@ -2054,9 +2055,8 @@ guint agent_timeout_add_with_context (NiceAgent *agent, guint interval,
g_source_set_callback (source, function, data, NULL);
id = g_source_attach (source, agent->main_context);
g_source_unref (source);
return id;
return source;
}
......
......@@ -537,13 +537,13 @@ gboolean conn_check_schedule_next (NiceAgent *agent)
nice_debug ("Agent %p : priv_conn_check_tick_unlocked returned %d", agent, res);
/* step: schedule timer if not running yet */
if (res && agent->conncheck_timer_id == 0) {
agent->conncheck_timer_id = agent_timeout_add_with_context (agent, agent->timer_ta, priv_conn_check_tick, agent);
if (res && agent->conncheck_timer_source == NULL) {
agent->conncheck_timer_source = agent_timeout_add_with_context (agent, agent->timer_ta, priv_conn_check_tick, agent);
}
/* step: also start the keepalive timer */
if (agent->keepalive_timer_id == 0) {
agent->keepalive_timer_id = agent_timeout_add_with_context (agent, NICE_AGENT_TIMER_TR_DEFAULT, priv_conn_keepalive_tick, agent);
if (agent->keepalive_timer_source == NULL) {
agent->keepalive_timer_source = agent_timeout_add_with_context (agent, NICE_AGENT_TIMER_TR_DEFAULT, priv_conn_keepalive_tick, agent);
}
}
......@@ -951,9 +951,10 @@ void conn_check_free (NiceAgent *agent)
}
}
if (agent->conncheck_timer_id) {
g_source_remove (agent->conncheck_timer_id),
agent->conncheck_timer_id = 0;
if (agent->conncheck_timer_source != NULL) {
g_source_destroy (agent->conncheck_timer_source);
g_source_unref (agent->conncheck_timer_source);
agent->conncheck_timer_source = NULL;
}
}
......
......@@ -117,9 +117,11 @@ void discovery_free (NiceAgent *agent)
agent->discovery_unsched_items = 0;
}
if (agent->discovery_timer_id)
g_source_remove (agent->discovery_timer_id),
agent->discovery_timer_id = 0;
if (agent->discovery_timer_source != NULL) {
g_source_destroy (agent->discovery_timer_source);
g_source_unref (agent->discovery_timer_source);
agent->discovery_timer_source = NULL;
}
}
/**
......@@ -843,11 +845,11 @@ void discovery_schedule (NiceAgent *agent)
if (agent->discovery_unsched_items > 0) {
if (agent->discovery_timer_id == 0) {
if (agent->discovery_timer_source == NULL) {
/* step: run first iteration immediately */
gboolean res = priv_discovery_tick_unlocked (agent);
if (res == TRUE) {
agent->discovery_timer_id = agent_timeout_add_with_context (agent, agent->timer_ta, priv_discovery_tick, agent);
agent->discovery_timer_source = agent_timeout_add_with_context (agent, agent->timer_ta, priv_discovery_tick, 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