+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>
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_src_link),
GstTCPClient * client)
{
int avail, fd;
+ gboolean ret;
fd = client->fd;
GST_LOG_OBJECT (sink, "select reports client read on fd %d of %d bytes",
fd, avail);
+ ret = TRUE;
+
if (avail == 0) {
/* client sent close, so remove it */
GST_DEBUG_OBJECT (sink, "client asked for close, removing on fd %d", fd);
- return FALSE;
+ ret = FALSE;
} else {
guint8 dummy[512];
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 {
- 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) {
GST_DEBUG_OBJECT (sink, "could not read bytes from fd %d: %s",
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;
}
avail -= nread;
}
while (avail > 0);
}
- return TRUE;
+ return ret;
}
static gboolean