poll.c File Reference

#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <assert.h>
#include <string.h>
#include <asterisk/poll-compat.h>

Include dependency graph for poll.c:

Go to the source code of this file.

Defines

#define MAX(a, b)   ((a) > (b) ? (a) : (b))

Functions

int poll (structpollfd *pArray, unsigned long n_fds, int timeout)


Define Documentation

#define MAX ( a,
 )     ((a) > (b) ? (a) : (b))

Definition at line 87 of file poll.c.


Function Documentation

int poll ( struct pollfd pArray,
unsigned long  n_fds,
int  timeout 
)

Definition at line 264 of file poll.c.

00270 {
00271     fd_set  read_descs;                          /* input file descs */
00272     fd_set  write_descs;                         /* output file descs */
00273     fd_set  except_descs;                        /* exception descs */
00274     struct  timeval stime;                       /* select() timeout value */
00275     int      ready_descriptors;                   /* function result */
00276     int      max_fd;                              /* maximum fd value */
00277     struct  timeval *pTimeout;                   /* actually passed */
00278 
00279     FD_ZERO (&read_descs);
00280     FD_ZERO (&write_descs);
00281     FD_ZERO (&except_descs);
00282 
00283     assert (pArray != (struct pollfd *) NULL);
00284 
00285     /* Map the poll() file descriptor list in the select() data structures. */
00286 
00287     max_fd = map_poll_spec (pArray, n_fds,
00288              &read_descs, &write_descs, &except_descs);
00289 
00290     /* Map the poll() timeout value in the select() timeout structure. */
00291 
00292     pTimeout = map_timeout (timeout, &stime);
00293 
00294     /* Make the select() call. */
00295 
00296     ready_descriptors = select (max_fd + 1, &read_descs, &write_descs,
00297             &except_descs, pTimeout);
00298 
00299     if (ready_descriptors >= 0)
00300     {
00301    map_select_results (pArray, n_fds,
00302              &read_descs, &write_descs, &except_descs);
00303     }
00304 
00305     return ready_descriptors;
00306 }


Generated on Wed Oct 28 17:01:00 2009 for Asterisk by  doxygen 1.5.6