Sat Aug 6 00:40:02 2011

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.


Define Documentation

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

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

Referenced by accept_thread(), ast_carefulwrite(), ast_el_read_char(), ast_io_wait(), ast_remotecontrol(), ast_wait_for_input(), ast_waitfor_nandfds(), cb_events(), get_input(), launch_netscript(), listener(), misdn_read(), monitor_sig_flags(), netconsole(), shaun_of_the_dead(), sound_thread(), and timed_read().


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 269 of file poll.c.

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

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


Generated on Sat Aug 6 00:40:02 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7