summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-09-19 08:57:53 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-09-19 08:57:53 +0100
commite5fbdbe605b0acc74e259a1618e2fe2304becade (patch)
treecea9c3ee22cf663b2f778ef977d15fb581afa008
parentb80bc3a17fd78f8b665509cb193e876b2d16497c (diff)
downloadlibnice-e5fbdbe605b0acc74e259a1618e2fe2304becade.tar.gz
agent: Add names to timer GSources
Modify the agent_timeout_add_with_context() utility function to automatically add names to the timer GSources it creates. This makes them a little easier to identify when debugging.
-rw-r--r--agent/agent-priv.h3
-rw-r--r--agent/agent.c10
-rw-r--r--agent/conncheck.c34
-rw-r--r--agent/discovery.c5
4 files changed, 33 insertions, 19 deletions
diff --git a/agent/agent-priv.h b/agent/agent-priv.h
index eab737c..0423aa8 100644
--- a/agent/agent-priv.h
+++ b/agent/agent-priv.h
@@ -206,7 +206,8 @@ void agent_signal_initial_binding_request_received (NiceAgent *agent, Stream *st
guint64 agent_candidate_pair_priority (NiceAgent *agent, NiceCandidate *local, NiceCandidate *remote);
-GSource *agent_timeout_add_with_context (NiceAgent *agent, guint interval, GSourceFunc function, gpointer data);
+GSource *agent_timeout_add_with_context (NiceAgent *agent, const gchar *name,
+ guint interval, GSourceFunc function, gpointer data);
StunUsageIceCompatibility agent_to_ice_compatibility (NiceAgent *agent);
StunUsageTurnCompatibility agent_to_turn_compatibility (NiceAgent *agent);
diff --git a/agent/agent.c b/agent/agent.c
index c536713..71f83a3 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -1813,7 +1813,8 @@ adjust_tcp_clock (NiceAgent *agent, Stream *stream, Component *component)
/* Prevent integer overflows */
if (interval < 0 || interval > G_MAXINT)
interval = G_MAXINT;
- component->tcp_clock = agent_timeout_add_with_context (agent, interval,
+ component->tcp_clock = agent_timeout_add_with_context (agent,
+ "Pseudo-TCP clock", interval,
notify_pseudo_tcp_socket_clock, component);
}
}
@@ -2618,7 +2619,7 @@ nice_agent_gather_candidates (
agent->upnp = gupnp_simple_igd_thread_new ();
agent->upnp_timer_source = agent_timeout_add_with_context (agent,
- agent->upnp_timeout, priv_upnp_timeout_cb, agent);
+ "UPnP timeout", agent->upnp_timeout, priv_upnp_timeout_cb, agent);
if (agent->upnp) {
g_signal_connect (agent->upnp, "mapped-external-port",
@@ -4963,8 +4964,8 @@ nice_agent_get_selected_socket (NiceAgent *agent, guint stream_id,
return g_socket;
}
-GSource* agent_timeout_add_with_context (NiceAgent *agent, guint interval,
- GSourceFunc function, gpointer data)
+GSource* agent_timeout_add_with_context (NiceAgent *agent, const gchar *name,
+ guint interval, GSourceFunc function, gpointer data)
{
GSource *source;
@@ -4972,6 +4973,7 @@ GSource* agent_timeout_add_with_context (NiceAgent *agent, guint interval,
source = g_timeout_source_new (interval);
+ g_source_set_name (source, name);
g_source_set_callback (source, function, data, NULL);
g_source_attach (source, agent->main_context);
diff --git a/agent/conncheck.c b/agent/conncheck.c
index 382e0b0..f149423 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -543,14 +543,14 @@ static gboolean priv_conn_keepalive_retransmissions_tick (gpointer pointer)
pair->keepalive.agent);
pair->keepalive.tick_source =
agent_timeout_add_with_context (pair->keepalive.agent,
- stun_timer_remainder (&pair->keepalive.timer),
- priv_conn_keepalive_retransmissions_tick, pair);
+ "Pair keepalive", stun_timer_remainder (&pair->keepalive.timer),
+ priv_conn_keepalive_retransmissions_tick, pair);
break;
case STUN_USAGE_TIMER_RETURN_SUCCESS:
pair->keepalive.tick_source =
agent_timeout_add_with_context (pair->keepalive.agent,
- stun_timer_remainder (&pair->keepalive.timer),
- priv_conn_keepalive_retransmissions_tick, pair);
+ "Pair keepalive", stun_timer_remainder (&pair->keepalive.timer),
+ priv_conn_keepalive_retransmissions_tick, pair);
break;
default:
/* Nothing to do. */
@@ -679,6 +679,7 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
p->keepalive.tick_source =
agent_timeout_add_with_context (p->keepalive.agent,
+ "Pair keepalive",
stun_timer_remainder (&p->keepalive.timer),
priv_conn_keepalive_retransmissions_tick, p);
} else {
@@ -824,12 +825,12 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick (gpointer pointe
stun_message_length (&cand->stun_message), (gchar *)cand->stun_buffer);
cand->tick_source = agent_timeout_add_with_context (cand->agent,
- stun_timer_remainder (&cand->timer),
+ "Candidate TURN refresh", stun_timer_remainder (&cand->timer),
priv_turn_allocate_refresh_retransmissions_tick, cand);
break;
case STUN_USAGE_TIMER_RETURN_SUCCESS:
cand->tick_source = agent_timeout_add_with_context (cand->agent,
- stun_timer_remainder (&cand->timer),
+ "Candidate TURN refresh", stun_timer_remainder (&cand->timer),
priv_turn_allocate_refresh_retransmissions_tick, cand);
break;
default:
@@ -894,7 +895,7 @@ static void priv_turn_allocate_refresh_tick_unlocked (CandidateRefresh *cand)
buffer_len, (gchar *)cand->stun_buffer);
cand->tick_source = agent_timeout_add_with_context (cand->agent,
- stun_timer_remainder (&cand->timer),
+ "Candidate TURN refresh", stun_timer_remainder (&cand->timer),
priv_turn_allocate_refresh_retransmissions_tick, cand);
}
@@ -946,12 +947,18 @@ gboolean conn_check_schedule_next (NiceAgent *agent)
/* step: schedule timer if not running yet */
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);
+ agent->conncheck_timer_source =
+ agent_timeout_add_with_context (agent,
+ "Connectivity check schedule", agent->timer_ta,
+ priv_conn_check_tick, agent);
}
/* step: also start the keepalive timer */
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);
+ agent->keepalive_timer_source =
+ agent_timeout_add_with_context (agent,
+ "Connectivity keepalive timeout", NICE_AGENT_TIMER_TR_DEFAULT,
+ priv_conn_keepalive_tick, agent);
}
nice_debug ("Agent %p : conn_check_schedule_next returning %d", agent, res);
@@ -2513,8 +2520,8 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
/* step: also start the refresh timer */
/* refresh should be sent 1 minute before it expires */
cand->timer_source =
- agent_timeout_add_with_context (agent, (lifetime - 60) * 1000,
- priv_turn_allocate_refresh_tick, cand);
+ agent_timeout_add_with_context (agent, "Candidate TURN refresh",
+ (lifetime - 60) * 1000, priv_turn_allocate_refresh_tick, cand);
nice_debug ("timer source is : %p", cand->timer_source);
@@ -2759,8 +2766,9 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
if (res == STUN_USAGE_TURN_RETURN_RELAY_SUCCESS) {
/* refresh should be sent 1 minute before it expires */
cand->timer_source =
- agent_timeout_add_with_context (cand->agent, (lifetime - 60) * 1000,
- priv_turn_allocate_refresh_tick, cand);
+ agent_timeout_add_with_context (cand->agent,
+ "Candidate TURN refresh", (lifetime - 60) * 1000,
+ priv_turn_allocate_refresh_tick, cand);
g_source_destroy (cand->tick_source);
g_source_unref (cand->tick_source);
diff --git a/agent/discovery.c b/agent/discovery.c
index b055807..c5d9220 100644
--- a/agent/discovery.c
+++ b/agent/discovery.c
@@ -1169,7 +1169,10 @@ void discovery_schedule (NiceAgent *agent)
/* step: run first iteration immediately */
gboolean res = priv_discovery_tick_unlocked (agent);
if (res == TRUE) {
- agent->discovery_timer_source = agent_timeout_add_with_context (agent, agent->timer_ta, priv_discovery_tick, agent);
+ agent->discovery_timer_source =
+ agent_timeout_add_with_context (agent,
+ "Candidate discovery tick", agent->timer_ta,
+ priv_discovery_tick, agent);
}
}
}