Commit 7137fe03 authored by Livio Madaro's avatar Livio Madaro Committed by Olivier Crête

agent: Read all socket data in nice_agent_g_source_cb

parent 0d2943b3
...@@ -2638,6 +2638,8 @@ nice_agent_g_source_cb ( ...@@ -2638,6 +2638,8 @@ nice_agent_g_source_cb (
agent_lock(); agent_lock();
for (;;)
{
if (g_source_is_destroyed (g_main_current_source ())) { if (g_source_is_destroyed (g_main_current_source ())) {
agent_unlock (); agent_unlock ();
return FALSE; return FALSE;
...@@ -2646,7 +2648,8 @@ nice_agent_g_source_cb ( ...@@ -2646,7 +2648,8 @@ nice_agent_g_source_cb (
len = _nice_agent_recv (agent, stream, component, ctx->socket, len = _nice_agent_recv (agent, stream, component, ctx->socket,
MAX_BUFFER_SIZE, buf); MAX_BUFFER_SIZE, buf);
if (len > 0 && component->tcp) { if (len > 0) {
if (component->tcp) {
g_object_add_weak_pointer (G_OBJECT (agent), (gpointer *)&agent); g_object_add_weak_pointer (G_OBJECT (agent), (gpointer *)&agent);
pseudo_tcp_socket_notify_packet (component->tcp, buf, len); pseudo_tcp_socket_notify_packet (component->tcp, buf, len);
if (agent) { if (agent) {
...@@ -2655,9 +2658,9 @@ nice_agent_g_source_cb ( ...@@ -2655,9 +2658,9 @@ nice_agent_g_source_cb (
} else { } else {
nice_debug ("Our agent got destroyed in notify_packet!!"); nice_debug ("Our agent got destroyed in notify_packet!!");
} }
} else if(len > 0 && agent->reliable) { } else if(agent->reliable) {
nice_debug ("Received data on a pseudo tcp FAILED component"); nice_debug ("Received data on a pseudo tcp FAILED component");
} else if (len > 0 && component->g_source_io_cb) { } else if (component->g_source_io_cb) {
gpointer data = component->data; gpointer data = component->data;
gint sid = stream->id; gint sid = stream->id;
gint cid = component->id; gint cid = component->id;
...@@ -2665,7 +2668,8 @@ nice_agent_g_source_cb ( ...@@ -2665,7 +2668,8 @@ nice_agent_g_source_cb (
/* Unlock the agent before calling the callback */ /* Unlock the agent before calling the callback */
agent_unlock(); agent_unlock();
callback (agent, sid, cid, len, buf, data); callback (agent, sid, cid, len, buf, data);
goto done; agent_lock();
}
} else if (len < 0) { } else if (len < 0) {
GSource *source = ctx->source; GSource *source = ctx->source;
...@@ -2679,12 +2683,16 @@ nice_agent_g_source_cb ( ...@@ -2679,12 +2683,16 @@ nice_agent_g_source_cb (
nice_debug ("Agent %p: unable to recv from socket %p. Detaching", agent, nice_debug ("Agent %p: unable to recv from socket %p. Detaching", agent,
ctx->socket); ctx->socket);
/* Error, stop */
break;
} else if (len == 0) {
/* Nothing left to read, stop */
break;
}
} }
agent_unlock(); agent_unlock();
done:
return TRUE; return TRUE;
} }
......
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