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.
This commit is contained in:
Wim Taymans 2007-04-26 08:48:30 +00:00
parent 88bf47c911
commit 45b77c57b4
2 changed files with 20 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2007-04-26 Wim Taymans <wim@fluendo.com>
* 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.
2007-04-26 Wim Taymans <wim@fluendo.com> 2007-04-26 Wim Taymans <wim@fluendo.com>
* gst/wavparse/gstwavparse.c: (gst_wavparse_perform_seek), * gst/wavparse/gstwavparse.c: (gst_wavparse_perform_seek),

View file

@ -451,13 +451,18 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
goto stopped; goto stopped;
} while (try_again); } while (try_again);
/* ask how much is available for reading on the socket, this is exactly one /* ask how much is available for reading on the socket, this should be exactly
* UDP packet. */ * 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) if ((ret = IOCTL_SOCKET (udpsrc->sock, FIONREAD, &readsize)) < 0)
goto ioctl_failed; goto ioctl_failed;
GST_LOG_OBJECT (udpsrc, "ioctl says %d bytes available", (int) readsize); GST_LOG_OBJECT (udpsrc, "ioctl says %d bytes available", (int) readsize);
if (!readsize)
goto nothing_to_read;
pktdata = g_malloc (readsize); pktdata = g_malloc (readsize);
pktsize = readsize; pktsize = readsize;
@ -516,6 +521,13 @@ ioctl_failed:
("ioctl failed %d: %s (%d)", ret, g_strerror (errno), errno)); ("ioctl failed %d: %s (%d)", ret, g_strerror (errno), errno));
return GST_FLOW_ERROR; 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: receive_error:
{ {
g_free (pktdata); g_free (pktdata);