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,53 +2638,61 @@ nice_agent_g_source_cb ( ...@@ -2638,53 +2638,61 @@ nice_agent_g_source_cb (
agent_lock(); agent_lock();
if (g_source_is_destroyed (g_main_current_source ())) { for (;;)
agent_unlock (); {
return FALSE; if (g_source_is_destroyed (g_main_current_source ())) {
} agent_unlock ();
return FALSE;
}
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) {
g_object_add_weak_pointer (G_OBJECT (agent), (gpointer *)&agent); if (component->tcp) {
pseudo_tcp_socket_notify_packet (component->tcp, buf, len); g_object_add_weak_pointer (G_OBJECT (agent), (gpointer *)&agent);
if (agent) { pseudo_tcp_socket_notify_packet (component->tcp, buf, len);
adjust_tcp_clock (agent, stream, component); if (agent) {
g_object_remove_weak_pointer (G_OBJECT (agent), (gpointer *)&agent); adjust_tcp_clock (agent, stream, component);
} else { g_object_remove_weak_pointer (G_OBJECT (agent), (gpointer *)&agent);
nice_debug ("Our agent got destroyed in notify_packet!!"); } else {
nice_debug ("Our agent got destroyed in notify_packet!!");
}
} else if(agent->reliable) {
nice_debug ("Received data on a pseudo tcp FAILED component");
} else if (component->g_source_io_cb) {
gpointer data = component->data;
gint sid = stream->id;
gint cid = component->id;
NiceAgentRecvFunc callback = component->g_source_io_cb;
/* Unlock the agent before calling the callback */
agent_unlock();
callback (agent, sid, cid, len, buf, data);
agent_lock();
}
} else if (len < 0) {
GSource *source = ctx->source;
nice_debug ("Agent %p: _nice_agent_recv returned %d, errno (%d) : %s",
agent, len, errno, g_strerror (errno));
component->gsources = g_slist_remove (component->gsources, source);
g_source_destroy (source);
g_source_unref (source);
/* We don't close the socket because it would be way too complicated to
* take care of every path where the socket might still be used.. */
nice_debug ("Agent %p: unable to recv from socket %p. Detaching", agent,
ctx->socket);
/* Error, stop */
break;
} else if (len == 0) {
/* Nothing left to read, stop */
break;
} }
} else if(len > 0 && agent->reliable) {
nice_debug ("Received data on a pseudo tcp FAILED component");
} else if (len > 0 && component->g_source_io_cb) {
gpointer data = component->data;
gint sid = stream->id;
gint cid = component->id;
NiceAgentRecvFunc callback = component->g_source_io_cb;
/* Unlock the agent before calling the callback */
agent_unlock();
callback (agent, sid, cid, len, buf, data);
goto done;
} else if (len < 0) {
GSource *source = ctx->source;
nice_debug ("Agent %p: _nice_agent_recv returned %d, errno (%d) : %s",
agent, len, errno, g_strerror (errno));
component->gsources = g_slist_remove (component->gsources, source);
g_source_destroy (source);
g_source_unref (source);
/* We don't close the socket because it would be way too complicated to
* take care of every path where the socket might still be used.. */
nice_debug ("Agent %p: unable to recv from socket %p. Detaching", agent,
ctx->socket);
} }
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