28 #define _XOPEN_SOURCE 700    32 #ifdef HAVE_SYS_SELECT_H    33 #include <sys/select.h>    36 #if !defined(HAVE_SELECT) && !defined(HAVE_POLL_FINE)    37 #error "We can't compile without select() or poll() support."    44 #include <sys/types.h>    73 int curl_poll(
struct pollfd ufds[], 
unsigned int nfds, 
int timeout_ms)
    75         return poll(ufds, nfds, timeout_ms);
    88 long curlx_tvdiff(
struct timeval newer, 
struct timeval older)
    90         return (newer.tv_sec - older.tv_sec) * 1000 +
    91                (long)(newer.tv_usec - older.tv_usec) / 1000;
    95 static int verify_sock(
int s)
    97         if (s < 0 || s >= FD_SETSIZE) {
   106 int curl_poll(
struct pollfd ufds[], 
unsigned int nfds, 
int timeout_ms)
   108         struct timeval pending_tv;
   109         struct timeval* ptimeout;
   115         struct timeval initial_tv = { 0, 0 };
   125         if (timeout_ms > 0) {
   126                 pending_ms = timeout_ms;
   127                 gettimeofday(&initial_tv, NULL);
   135         for (i = 0; i < nfds; i++) {
   137                 if (ufds[i].fd == -1)
   139                 ufds[i].fd = verify_sock(ufds[i].fd);
   140                 if (ufds[i].events & (POLLIN | POLLOUT | POLLPRI |
   141                                       POLLRDNORM | POLLWRNORM | POLLRDBAND)) {
   142                         if (ufds[i].fd > maxfd)
   144                         if (ufds[i].events & (POLLRDNORM | POLLIN))
   145                                 FD_SET(ufds[i].fd, &fds_read);
   146                         if (ufds[i].events & (POLLWRNORM | POLLOUT))
   147                                 FD_SET(ufds[i].fd, &fds_write);
   148                         if (ufds[i].events & (POLLRDBAND | POLLPRI))
   149                                 FD_SET(ufds[i].fd, &fds_err);
   153         ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
   155         if (timeout_ms > 0) {
   156                 pending_tv.tv_sec = pending_ms / 1000;
   157                 pending_tv.tv_usec = (pending_ms % 1000) * 1000;
   158         } 
else if (!timeout_ms) {
   159                 pending_tv.tv_sec = 0;
   160                 pending_tv.tv_usec = 0;
   162         r = select((
int)maxfd + 1, &fds_read, &fds_write, &fds_err,
   169         for (i = 0; i < nfds; i++) {
   171                 if (ufds[i].fd == -1)
   173                 if (FD_ISSET(ufds[i].fd, &fds_read))
   174                         ufds[i].revents |= POLLIN;
   175                 if (FD_ISSET(ufds[i].fd, &fds_write))
   176                         ufds[i].revents |= POLLOUT;
   177                 if (FD_ISSET(ufds[i].fd, &fds_err))
   178                         ufds[i].revents |= POLLPRI;
   179                 if (ufds[i].revents != 0)
 
Wrapper for poll(2) using select(2) when poll() is unavailable. 
logchannel_t
Log channels used to filter messages. 
#define log_notice(fmt,...)
Log a notice message.