gst/tcp/gstmultifdsink.c: Make sure we don't try to read more from a client that what ioctl says us or we deadlock.
Original commit message from CVS: * gst/tcp/gstmultifdsink.c: (gst_multifdsink_class_init), (gst_multifdsink_add), (gst_multifdsink_get_stats), (gst_multifdsink_client_remove), (gst_multifdsink_handle_client_read), (gst_multifdsink_handle_client_write), (gst_multifdsink_queue_buffer), (gst_multifdsink_handle_clients): Make sure we don't try to read more from a client that what ioctl says us or we deadlock.
This commit is contained in:
parent
fa9cca2cc4
commit
fd78bb16f1
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2004-08-06 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/tcp/gstmultifdsink.c: (gst_multifdsink_class_init),
|
||||||
|
(gst_multifdsink_add), (gst_multifdsink_get_stats),
|
||||||
|
(gst_multifdsink_client_remove),
|
||||||
|
(gst_multifdsink_handle_client_read),
|
||||||
|
(gst_multifdsink_handle_client_write),
|
||||||
|
(gst_multifdsink_queue_buffer), (gst_multifdsink_handle_clients):
|
||||||
|
Make sure we don't try to read more from a client that what
|
||||||
|
ioctl says us or we deadlock.
|
||||||
|
|
||||||
2004-08-05 Thomas Vander Stichele <thomas at apestaart dot org>
|
2004-08-05 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_src_link),
|
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_src_link),
|
||||||
|
@ -474,6 +474,7 @@ gst_multifdsink_handle_client_read (GstMultiFdSink * sink,
|
|||||||
GstTCPClient * client)
|
GstTCPClient * client)
|
||||||
{
|
{
|
||||||
int avail, fd;
|
int avail, fd;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
fd = client->fd;
|
fd = client->fd;
|
||||||
|
|
||||||
@ -482,27 +483,39 @@ gst_multifdsink_handle_client_read (GstMultiFdSink * sink,
|
|||||||
GST_LOG_OBJECT (sink, "select reports client read on fd %d of %d bytes",
|
GST_LOG_OBJECT (sink, "select reports client read on fd %d of %d bytes",
|
||||||
fd, avail);
|
fd, avail);
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
if (avail == 0) {
|
if (avail == 0) {
|
||||||
/* client sent close, so remove it */
|
/* client sent close, so remove it */
|
||||||
GST_DEBUG_OBJECT (sink, "client asked for close, removing on fd %d", fd);
|
GST_DEBUG_OBJECT (sink, "client asked for close, removing on fd %d", fd);
|
||||||
return FALSE;
|
ret = FALSE;
|
||||||
} else {
|
} else {
|
||||||
guint8 dummy[512];
|
guint8 dummy[512];
|
||||||
gint nread;
|
gint nread;
|
||||||
|
|
||||||
/* just Read 'n' Drop */
|
/* just Read 'n' Drop, could also just drop the client as it's not supposed
|
||||||
|
* to write to us except for closing the socket, I guess it's because we
|
||||||
|
* like to listen to our customers. */
|
||||||
do {
|
do {
|
||||||
nread = read (fd, dummy, 512);
|
/* this is the maximum we can read */
|
||||||
|
gint to_read = MIN (avail, 512);
|
||||||
|
|
||||||
|
nread = read (fd, dummy, to_read);
|
||||||
if (nread < -1) {
|
if (nread < -1) {
|
||||||
GST_DEBUG_OBJECT (sink, "could not read bytes from fd %d: %s",
|
GST_DEBUG_OBJECT (sink, "could not read bytes from fd %d: %s",
|
||||||
fd, g_strerror (errno));
|
fd, g_strerror (errno));
|
||||||
|
ret = FALSE;
|
||||||
|
break;
|
||||||
|
} else if (nread == 0) {
|
||||||
|
GST_WARNING_OBJECT (sink, "fd %d: gave 0 bytes in read, removing", fd);
|
||||||
|
ret = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
avail -= nread;
|
avail -= nread;
|
||||||
}
|
}
|
||||||
while (avail > 0);
|
while (avail > 0);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user