conncheck: fix a buggy state transition
authorFabrice Bellet <fabrice@bellet.info>
Mon, 23 Nov 2020 21:53:45 +0000 (22:53 +0100)
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>
Mon, 7 Dec 2020 22:12:04 +0000 (22:12 +0000)
The previous patch handling tcp disconnections forgot a case when the
selected pair is removed, while in state ready, and in that situation,
we should not jump back to connecting state, but fail instead. Just like
we did at the beginning of the function.

agent/conncheck.c

index a74112d..680787d 100644 (file)
@@ -4906,10 +4906,14 @@ conn_check_prune_socket (NiceAgent *agent, NiceStream *stream, NiceComponent *co
     if (p_count == 0)
       agent_signal_component_state_change (agent,
         stream->id, component->id, NICE_COMPONENT_STATE_FAILED);
-    else if (p_nominated == 0 &&
-        component->state >= NICE_COMPONENT_STATE_CONNECTED)
-      agent_signal_component_state_change (agent,
-        stream->id, component->id, NICE_COMPONENT_STATE_CONNECTING);
+    else if (p_nominated == 0) {
+      if (component->state == NICE_COMPONENT_STATE_READY)
+          agent_signal_component_state_change (agent,
+            stream->id, component->id, NICE_COMPONENT_STATE_FAILED);
+      else if (component->state == NICE_COMPONENT_STATE_CONNECTED)
+          agent_signal_component_state_change (agent,
+            stream->id, component->id, NICE_COMPONENT_STATE_CONNECTING);
+    }
   }
 
   /* outside of the previous loop, because it may