From c7fa24cb75357fbee9dd5f290ef3316be79b2376 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Fri, 6 May 2011 20:04:34 +0200 Subject: [PATCH] handle the case nfds > 1 --- libsndio/sio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libsndio/sio.c b/libsndio/sio.c index 8785739..493aeec 100644 --- a/libsndio/sio.c +++ b/libsndio/sio.c @@ -33,6 +33,7 @@ #include "bsd-compat.h" #define SIO_PAR_MAGIC 0x83b905a4 +#define SIO_MAXNFDS 8 struct sio_backend { char *prefix; @@ -222,19 +223,21 @@ sio_getcap(struct sio_hdl *hdl, struct sio_cap *cap) static int sio_psleep(struct sio_hdl *hdl, int event) { - struct pollfd pfd; + struct pollfd pfd[SIO_MAXNFDS]; int revents; + nfds_t nfds; + nfds = sio_nfds(hdl); for (;;) { - sio_pollfd(hdl, &pfd, event); - while (poll(&pfd, 1, -1) < 0) { + sio_pollfd(hdl, pfd, event); + while (poll(pfd, nfds, -1) < 0) { if (errno == EINTR) continue; DPERROR("sio_psleep: poll"); hdl->eof = 1; return 0; } - revents = sio_revents(hdl, &pfd); + revents = sio_revents(hdl, pfd); if (revents & POLLHUP) { DPRINTF("sio_psleep: hang-up\n"); return 0;