From ce4b2c7f7243a7c41f8e302ed009d40538fd6a57 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 12 Sep 2020 12:44:05 -0700 Subject: [PATCH] remove disabled poll() code The macro _lib_poll was undefined on all platforms that have select.h, which is everything except Windows. Poll does not exist on Windows, so it was also disabled there. Related to #1422 and #1521. --- lib/sfio/sfhdr.h | 26 -------------------------- lib/sfio/sfpkrd.c | 21 +-------------------- lib/sfio/sfpoll.c | 38 -------------------------------------- 3 files changed, 1 insertion(+), 84 deletions(-) diff --git a/lib/sfio/sfhdr.h b/lib/sfio/sfhdr.h index 1b0a54ad0..9cda8a815 100644 --- a/lib/sfio/sfhdr.h +++ b/lib/sfio/sfhdr.h @@ -52,7 +52,6 @@ extern "C" { #ifdef _SFBINARY_H #undef HAVE_SYS_ST #undef HAVE_STAT_H -#undef _lib_poll #undef _stream_peek #undef _socket_peek #undef HAVE_VFORK_H @@ -102,23 +101,6 @@ extern "C" { #define POOLMTXRETURN(p,v) { return(v); } /* functions for polling readiness of streams */ -#ifdef HAVE_SELECT -#undef _lib_poll -#else -#if _lib_poll_fd_1 || _lib_poll_fd_2 -#define _lib_poll 1 -#endif -#endif /*HAVE_SELECT*/ - -#ifdef _lib_poll -#include - -#if _lib_poll_fd_1 -#define SFPOLL(pfd,n,tm) poll((pfd),(ulong)(n),(tm)) -#else -#define SFPOLL(pfd,n,tm) poll((ulong)(n),(pfd),(tm)) -#endif -#endif /*_lib_poll*/ #if _stream_peek #include @@ -786,14 +768,6 @@ extern "C" { extern pid_t vfork(void); #endif /*HAVE_VFORK*/ -#ifdef _lib_poll -#if _lib_poll_fd_1 - extern int poll(struct pollfd *, ulong, int); -#else - extern int poll(ulong, struct pollfd *, int); -#endif -#endif /*_lib_poll*/ - #endif /*_SFHDR_H*/ #ifdef __cplusplus } diff --git a/lib/sfio/sfpkrd.c b/lib/sfio/sfpkrd.c index fd666ff3e..09fc074b3 100644 --- a/lib/sfio/sfpkrd.c +++ b/lib/sfio/sfpkrd.c @@ -96,25 +96,6 @@ ssize_t sfpkrd(int fd, void * argbuf, size_t n, int rc, long tm, /* let select be interrupted instead of recv which autoresumes */ (t & SOCKET_PEEK)) { r = -2; -#if _lib_poll - if (r == -2) { - struct pollfd po; - po.fd = fd; - po.events = POLLIN; - po.revents = 0; - - if ((r = SFPOLL(&po, 1, tm)) < 0) { - if (errno == EINTR) - return -1; - else if (errno == EAGAIN) { - errno = 0; - continue; - } else - r = -2; - } else - r = (po.revents & POLLIN) ? 1 : -1; - } -#endif /*_lib_poll*/ #ifdef HAVE_SELECT if (r == -2) { fd_set rd; @@ -142,7 +123,7 @@ ssize_t sfpkrd(int fd, void * argbuf, size_t n, int rc, long tm, } #endif /*HAVE_SELECT*/ if (r == -2) { -#if !_lib_poll && !defined(HAVE_SELECT) /* both poll and select cann't be used */ +#if !defined(HAVE_SELECT) /* select can't be used */ #ifdef FIONREAD /* quick and dirty check for availability */ long nsec = tm < 0 ? 0 : (tm + 999) / 1000; while (nsec > 0 && r < 0) { diff --git a/lib/sfio/sfpoll.c b/lib/sfio/sfpoll.c index 1453eee1d..90fd44eaf 100644 --- a/lib/sfio/sfpoll.c +++ b/lib/sfio/sfpoll.c @@ -117,44 +117,6 @@ int sfpoll(Sfio_t ** fa, int n, int tm) } } -#if _lib_poll - if (c > 0) { - struct pollfd *fds; - - /* construct the poll array */ - if (!(fds = (struct pollfd *) malloc(c * sizeof(struct pollfd)))) - return -1; - for (r = 0; r < c; r++) { - fds[r].fd = fa[check[r]]->file; - fds[r].events = - (fa[check[r]]->mode & SF_READ) ? POLLIN : POLLOUT; - fds[r].revents = 0; - } - - for (;;) { /* this loop takes care of interrupts */ - if ((r = SFPOLL(fds, c, tm)) == 0) - break; - else if (r < 0) { - if (errno == EINTR || errno == EAGAIN) { - errno = 0; - continue; - } else - break; - } - - for (r = 0; r < c; ++r) { - f = fa[check[r]]; - if (((f->mode & SF_READ) && (fds[r].revents & POLLIN)) || - ((f->mode & SF_WRITE) && (fds[r].revents & POLLOUT))) - status[check[r]] = 1; - } - break; - } - - free((void *) fds); - } -#endif /*_lib_poll*/ - #ifdef HAVE_SELECT if (c > 0) { fd_set rd, wr; -- 2.40.0