summaryrefslogtreecommitdiff
path: root/gst/gstpoll.c
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2009-10-12 10:01:01 +0200
committerEdward Hervey <bilboed@bilboed.com>2009-10-12 10:01:01 +0200
commit3254f19c6fbe61f72a6dd8c1c10349931a60bfe9 (patch)
tree138868f80ab8ce681aa64ba6e1c7f7f4a0f84f72 /gst/gstpoll.c
parent95413683fad91f2e186c97def6dac469ec98a307 (diff)
gstpoll: Use the error fdset when using select/pselect.
This is needed to properly detect fds that are closed or that got an error
Diffstat (limited to 'gst/gstpoll.c')
-rw-r--r--gst/gstpoll.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gst/gstpoll.c b/gst/gstpoll.c
index 821f6ddd0..00cd296b1 100644
--- a/gst/gstpoll.c
+++ b/gst/gstpoll.c
@@ -275,13 +275,15 @@ choose_mode (const GstPoll * set, GstClockTime timeout)
#ifndef G_OS_WIN32
static gint
-pollfd_to_fd_set (GstPoll * set, fd_set * readfds, fd_set * writefds)
+pollfd_to_fd_set (GstPoll * set, fd_set * readfds, fd_set * writefds,
+ fd_set * errorfds)
{
gint max_fd = -1;
guint i;
FD_ZERO (readfds);
FD_ZERO (writefds);
+ FD_ZERO (errorfds);
g_mutex_lock (set->lock);
@@ -293,6 +295,8 @@ pollfd_to_fd_set (GstPoll * set, fd_set * readfds, fd_set * writefds)
FD_SET (pfd->fd, readfds);
if (pfd->events & POLLOUT)
FD_SET (pfd->fd, writefds);
+ if (pfd->events)
+ FD_SET (pfd->fd, errorfds);
if (pfd->fd > max_fd)
max_fd = pfd->fd;
}
@@ -304,7 +308,8 @@ pollfd_to_fd_set (GstPoll * set, fd_set * readfds, fd_set * writefds)
}
static void
-fd_set_to_pollfd (GstPoll * set, fd_set * readfds, fd_set * writefds)
+fd_set_to_pollfd (GstPoll * set, fd_set * readfds, fd_set * writefds,
+ fd_set * errorfds)
{
guint i;
@@ -318,6 +323,8 @@ fd_set_to_pollfd (GstPoll * set, fd_set * readfds, fd_set * writefds)
pfd->revents |= POLLIN;
if (FD_ISSET (pfd->fd, writefds))
pfd->revents |= POLLOUT;
+ if (FD_ISSET (pfd->fd, errorfds))
+ pfd->revents |= POLLERR;
}
}
@@ -1179,9 +1186,10 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout)
#ifndef G_OS_WIN32
fd_set readfds;
fd_set writefds;
+ fd_set errorfds;
gint max_fd;
- max_fd = pollfd_to_fd_set (set, &readfds, &writefds);
+ max_fd = pollfd_to_fd_set (set, &readfds, &writefds, &errorfds);
if (mode == GST_POLL_MODE_SELECT) {
struct timeval tv;
@@ -1194,7 +1202,7 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout)
tvptr = NULL;
}
- res = select (max_fd + 1, &readfds, &writefds, NULL, tvptr);
+ res = select (max_fd + 1, &readfds, &writefds, &errorfds, tvptr);
} else {
#ifdef HAVE_PSELECT
struct timespec ts;
@@ -1207,12 +1215,13 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout)
tsptr = NULL;
}
- res = pselect (max_fd + 1, &readfds, &writefds, NULL, tsptr, NULL);
+ res =
+ pselect (max_fd + 1, &readfds, &writefds, &errorfds, tsptr, NULL);
#endif
}
- if (res > 0) {
- fd_set_to_pollfd (set, &readfds, &writefds);
+ if (res >= 0) {
+ fd_set_to_pollfd (set, &readfds, &writefds, &errorfds);
}
#else /* G_OS_WIN32 */
g_assert_not_reached ();