summaryrefslogtreecommitdiffstats
path: root/gst/udp/gstudpsrc.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-04-26 08:48:30 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-04-26 08:48:30 +0000
commit45b77c57b4d71ac737e31a28688065c15c6f68f0 (patch)
treef83233a5d1ab9a2ab7cd3a79109e56169380fa09 /gst/udp/gstudpsrc.c
parent88bf47c911aedc673e02e2369ad161ae0a7029d0 (diff)
gst/udp/gstudpsrc.c: Handle the case where there are exactly 0 bytes to read and the ioctl did not report an error. F...
Original commit message from CVS: * gst/udp/gstudpsrc.c: (gst_udpsrc_create): Handle the case where there are exactly 0 bytes to read and the ioctl did not report an error. Fixes #433530.
Diffstat (limited to 'gst/udp/gstudpsrc.c')
-rw-r--r--gst/udp/gstudpsrc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c
index e80a74c8..6c6f701d 100644
--- a/gst/udp/gstudpsrc.c
+++ b/gst/udp/gstudpsrc.c
@@ -451,13 +451,18 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
goto stopped;
} while (try_again);
- /* ask how much is available for reading on the socket, this is exactly one
- * UDP packet. */
+ /* ask how much is available for reading on the socket, this should be exactly
+ * one UDP packet. We will check the return value, though, because in some
+ * case it can return 0 and we don't want a 0 sized buffer. */
+ readsize = 0;
if ((ret = IOCTL_SOCKET (udpsrc->sock, FIONREAD, &readsize)) < 0)
goto ioctl_failed;
GST_LOG_OBJECT (udpsrc, "ioctl says %d bytes available", (int) readsize);
+ if (!readsize)
+ goto nothing_to_read;
+
pktdata = g_malloc (readsize);
pktsize = readsize;
@@ -516,6 +521,13 @@ ioctl_failed:
("ioctl failed %d: %s (%d)", ret, g_strerror (errno), errno));
return GST_FLOW_ERROR;
}
+nothing_to_read:
+ {
+ GST_ELEMENT_ERROR (udpsrc, RESOURCE, READ, (NULL),
+ ("ioctl returned readsize 0 %d: %s (%d)", ret, g_strerror (errno),
+ errno));
+ return GST_FLOW_ERROR;
+ }
receive_error:
{
g_free (pktdata);