[Pkg-telepathy-commits] [libnice] 112/265: agent: Simplify control flow in agent_recv_locked()

Simon McVittie smcv at debian.org
Wed May 14 12:04:58 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 bc527dcf63e9fb71e7432252a3371def265ba1e7
Author: Philip Withnall <philip.withnall at collabora.co.uk>
Date:   Wed Jan 15 14:10:34 2014 +0000

    agent: Simplify control flow in agent_recv_locked()
    
    This introduces no functional changes.
---
 agent/agent.c | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/agent/agent.c b/agent/agent.c
index 771a568..d332dc7 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -2466,40 +2466,41 @@ agent_recv_locked (
 
   for (item = component->turn_servers; item; item = g_list_next (item)) {
     TurnServer *turn = item->data;
-    if (nice_address_equal (&from, &turn->server)) {
-      GSList * i = NULL;
+    GSList *i = NULL;
+
+    if (!nice_address_equal (&from, &turn->server))
+      continue;
+
 #ifndef NDEBUG
-      nice_debug ("Agent %p : Packet received from TURN server candidate.",
-          agent);
+    nice_debug ("Agent %p : Packet received from TURN server candidate.",
+        agent);
 #endif
-      for (i = component->local_candidates; i; i = i->next) {
-        NiceCandidate *cand = i->data;
-        if (cand->type == NICE_CANDIDATE_TYPE_RELAYED &&
-            cand->stream_id == stream->id &&
-            cand->component_id == component->id) {
-          len = nice_turn_socket_parse_recv (cand->sockptr, &socket,
-              &from, len, (gchar *) local_buf, &from, (gchar *) local_buf, len);
-        }
+
+    for (i = component->local_candidates; i; i = i->next) {
+      NiceCandidate *cand = i->data;
+
+      if (cand->type == NICE_CANDIDATE_TYPE_RELAYED &&
+          cand->stream_id == stream->id &&
+          cand->component_id == component->id) {
+        len = nice_turn_socket_parse_recv (cand->sockptr, &socket,
+            &from, len, (gchar *) local_buf, &from, (gchar *) local_buf, len);
       }
-      break;
     }
   }
 
   agent->media_after_tick = TRUE;
 
+  /* If the message’s stated length is equal to its actual length, it’s probably
+   * a STUN message; otherwise it’s probably data. */
   if (stun_message_validate_buffer_length ((uint8_t *) local_buf, (size_t) len,
       (agent->compatibility != NICE_COMPATIBILITY_OC2007 &&
-       agent->compatibility != NICE_COMPATIBILITY_OC2007R2)) != len)
-    /* If the retval is not 0, it’s not a valid STUN packet; probably data. */
-    goto handle_tcp;
-
-
-  if (conn_check_handle_inbound_stun (agent, stream, component, socket,
-          &from, (gchar *) local_buf, len))
-    /* handled STUN message*/
+       agent->compatibility != NICE_COMPATIBILITY_OC2007R2)) == len &&
+      conn_check_handle_inbound_stun (agent, stream, component, socket,
+          &from, (gchar *) local_buf, len)) {
+    /* Handled STUN message. */
     return 0;
+  }
 
-handle_tcp:
   /* Unhandled STUN; try handling TCP data, then pass to the client. */
   if (len > 0 && component->tcp) {
     /* If we don’t yet have an underlying selected socket, queue up the incoming

-- 
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