[Pkg-telepathy-commits] [libnice] 43/265: agent: Read all socket data in nice_agent_g_source_cb
Simon McVittie
smcv at debian.org
Wed May 14 12:04:51 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 7137fe0388852c465accff59172325c9c097f517
Author: Livio Madaro <livio.madaro at telecomitalia.it>
Date: Tue Dec 10 12:18:03 2013 +0100
agent: Read all socket data in nice_agent_g_source_cb
---
agent/agent.c | 86 ++++++++++++++++++++++++++++++++---------------------------
1 file changed, 47 insertions(+), 39 deletions(-)
diff --git a/agent/agent.c b/agent/agent.c
index 315d8d8..3b0a35d 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -2638,53 +2638,61 @@ nice_agent_g_source_cb (
agent_lock();
- if (g_source_is_destroyed (g_main_current_source ())) {
- agent_unlock ();
- return FALSE;
- }
+ for (;;)
+ {
+ 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);
- if (len > 0 && component->tcp) {
- g_object_add_weak_pointer (G_OBJECT (agent), (gpointer *)&agent);
- pseudo_tcp_socket_notify_packet (component->tcp, buf, len);
- if (agent) {
- adjust_tcp_clock (agent, stream, component);
- g_object_remove_weak_pointer (G_OBJECT (agent), (gpointer *)&agent);
- } else {
- nice_debug ("Our agent got destroyed in notify_packet!!");
+ if (len > 0) {
+ if (component->tcp) {
+ g_object_add_weak_pointer (G_OBJECT (agent), (gpointer *)&agent);
+ pseudo_tcp_socket_notify_packet (component->tcp, buf, len);
+ if (agent) {
+ adjust_tcp_clock (agent, stream, component);
+ g_object_remove_weak_pointer (G_OBJECT (agent), (gpointer *)&agent);
+ } 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();
- done:
-
return TRUE;
}
--
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