Wed Aug 7 17:16:09 2019

Asterisk developer's documentation


poll-compat.h File Reference

#include "asterisk/select.h"
#include <sys/poll.h>

Go to the source code of this file.

Defines

#define ast_poll(a, b, c)   poll(a, b, c)

Functions

int ast_poll2 (struct pollfd *pArray, unsigned long n_fds, struct timeval *tv)
 Same as poll(2), except the time is specified in microseconds and the tv argument is modified to indicate the time remaining.
static int ast_poll_fd_index (struct pollfd *haystack, int nfds, int needle)
 Shortcut for conversion of FD_ISSET to poll(2)-based.

Define Documentation

#define ast_poll ( a,
b,
 )     poll(a, b, c)

Function Documentation

int ast_poll2 ( struct pollfd *  pArray,
unsigned long  n_fds,
struct timeval *  tv 
)

Same as poll(2), except the time is specified in microseconds and the tv argument is modified to indicate the time remaining.

Definition at line 268 of file poll.c.

References ast_select(), ast_tv(), ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), and FD_ZERO.

Referenced by do_monitor().

00269 {
00270 #if !defined(AST_POLL_COMPAT)
00271    struct timeval start = ast_tvnow();
00272 #if defined(HAVE_PPOLL)
00273    struct timespec ts = { tv ? tv->tv_sec : 0, tv ? tv->tv_usec * 1000 : 0 };
00274    int res = ppoll(pArray, n_fds, tv ? &ts : NULL, NULL);
00275 #else
00276    int res = poll(pArray, n_fds, tv ? tv->tv_sec * 1000 + tv->tv_usec / 1000 : -1);
00277 #endif
00278    struct timeval after = ast_tvnow();
00279    if (res > 0 && tv && ast_tvdiff_ms(ast_tvadd(*tv, start), after) > 0) {
00280       *tv = ast_tvsub(*tv, ast_tvsub(after, start));
00281    } else if (res > 0 && tv) {
00282       *tv = ast_tv(0, 0);
00283    }
00284    return res;
00285 #else
00286    ast_fdset read_descs, write_descs, except_descs;
00287    int ready_descriptors, max_fd = 0;
00288 
00289    FD_ZERO(&read_descs);
00290    FD_ZERO(&write_descs);
00291    FD_ZERO(&except_descs);
00292 
00293    if (pArray) {
00294       max_fd = map_poll_spec(pArray, n_fds, &read_descs, &write_descs, &except_descs);
00295    }
00296 
00297    ready_descriptors = ast_select(max_fd + 1, &read_descs, &write_descs, &except_descs, tv);
00298 
00299    if (ready_descriptors >= 0) {
00300       map_select_results(pArray, n_fds, &read_descs, &write_descs, &except_descs);
00301    }
00302 
00303    return ready_descriptors;
00304 #endif
00305 }

static int ast_poll_fd_index ( struct pollfd *  haystack,
int  nfds,
int  needle 
) [inline, static]

Shortcut for conversion of FD_ISSET to poll(2)-based.

Definition at line 128 of file poll-compat.h.

Referenced by do_pktccops().

00129 {
00130    int i;
00131    for (i = 0; i < nfds; i++) {
00132       if (haystack[i].fd == needle) {
00133          return i;
00134       }
00135    }
00136    return -1;
00137 }


Generated on 7 Aug 2019 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1