Commit bd46f868 authored by Kai Vehmanen's avatar Kai Vehmanen

Fixed a severe bug where an ICMP error response would cause glib mainloop go into busyloop state.

darcs-hash:20070830070543-77cd4-2fc520043e837a9ed044717564573bf613cf7c6c.gz
parent 1877b999
...@@ -977,9 +977,9 @@ nice_agent_set_remote_candidates (NiceAgent *agent, guint stream_id, guint compo ...@@ -977,9 +977,9 @@ nice_agent_set_remote_candidates (NiceAgent *agent, guint stream_id, guint compo
* Reads data from a ready, nonblocking socket attached to an ICE * Reads data from a ready, nonblocking socket attached to an ICE
* stream component. * stream component.
* *
* @return number of octets received, or zero on error * @return number of octets received, or negative on error
*/ */
static guint static gint
_nice_agent_recv ( _nice_agent_recv (
NiceAgent *agent, NiceAgent *agent,
Stream *stream, Stream *stream,
...@@ -989,13 +989,13 @@ _nice_agent_recv ( ...@@ -989,13 +989,13 @@ _nice_agent_recv (
gchar *buf) gchar *buf)
{ {
NiceAddress from; NiceAddress from;
guint len; gint len;
len = nice_udp_socket_recv (udp_socket, &from, len = nice_udp_socket_recv (udp_socket, &from,
buf_len, buf); buf_len, buf);
#ifndef NDEBUG #ifndef NDEBUG
{ if (len >= 0) {
gchar tmpbuf[INET6_ADDRSTRLEN]; gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (&from, tmpbuf); nice_address_to_string (&from, tmpbuf);
g_debug ("Packet received on local socket %u from %s:%u (%u octets).", udp_socket->fileno, tmpbuf, from.port, len); g_debug ("Packet received on local socket %u from %s:%u (%u octets).", udp_socket->fileno, tmpbuf, from.port, len);
...@@ -1005,7 +1005,7 @@ _nice_agent_recv ( ...@@ -1005,7 +1005,7 @@ _nice_agent_recv (
if (len == 0) if (len == 0)
return 0; return 0;
if (len > buf_len) if ((guint)len > buf_len)
{ {
/* buffer is not big enough to accept this packet */ /* buffer is not big enough to accept this packet */
/* XXX: test this case */ /* XXX: test this case */
...@@ -1059,7 +1059,7 @@ nice_agent_recv ( ...@@ -1059,7 +1059,7 @@ nice_agent_recv (
guint buf_len, guint buf_len,
gchar *buf) gchar *buf)
{ {
guint len = 0; gint len = 0;
fd_set fds; fd_set fds;
guint max_fd = 0; guint max_fd = 0;
gint num_readable; gint num_readable;
...@@ -1104,7 +1104,7 @@ nice_agent_recv ( ...@@ -1104,7 +1104,7 @@ nice_agent_recv (
len = _nice_agent_recv (agent, stream, component, socket, len = _nice_agent_recv (agent, stream, component, socket,
buf_len, buf); buf_len, buf);
if (len > 0) if (len >= 0)
return len; return len;
} }
} }
...@@ -1524,7 +1524,9 @@ static gboolean priv_attach_new_stream (NiceAgent *agent, Stream *stream) ...@@ -1524,7 +1524,9 @@ static gboolean priv_attach_new_stream (NiceAgent *agent, Stream *stream)
GSList *modified_list; GSList *modified_list;
io = g_io_channel_unix_new (udp_socket->fileno); io = g_io_channel_unix_new (udp_socket->fileno);
source = g_io_create_watch (io, G_IO_IN); /* note: without G_IO_ERR the glib mainloop goes into
* busyloop if errors are encountered */
source = g_io_create_watch (io, G_IO_IN | G_IO_ERR);
ctx = io_ctx_new (agent, stream, component, udp_socket); ctx = io_ctx_new (agent, stream, component, udp_socket);
g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb, g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb,
ctx, (GDestroyNotify) io_ctx_free); ctx, (GDestroyNotify) io_ctx_free);
......
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