From d1bc5687d429a03f33c95e5e5b6008d577a4a0e4 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Mon, 9 May 2011 17:34:15 +0000 Subject: in sio_psleep(), use an array of SIO_MAXNFDS pollfd strucures rather than a single one. No behaviour change --- lib/libsndio/sio.c | 12 +++++++----- lib/libsndio/sio_priv.h | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/libsndio') diff --git a/lib/libsndio/sio.c b/lib/libsndio/sio.c index af15bdac0a8..1b1376c7d4f 100644 --- a/lib/libsndio/sio.c +++ b/lib/libsndio/sio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio.c,v 1.5 2011/05/06 10:25:17 ratchov Exp $ */ +/* $OpenBSD: sio.c,v 1.6 2011/05/09 17:34:14 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -216,19 +216,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; diff --git a/lib/libsndio/sio_priv.h b/lib/libsndio/sio_priv.h index 1d7ed73e7b1..385a3a17b27 100644 --- a/lib/libsndio/sio_priv.h +++ b/lib/libsndio/sio_priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sio_priv.h,v 1.2 2011/04/16 10:52:22 ratchov Exp $ */ +/* $OpenBSD: sio_priv.h,v 1.3 2011/05/09 17:34:14 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -20,6 +20,8 @@ #include #include "sndio.h" +#define SIO_MAXNFDS 4 + /* * private ``handle'' structure */ -- cgit v1.2.3