#include <sys/time.h>
#include <sys/select.h>
#include <errno.h>
#include "asterisk/compat.h"
Go to the source code of this file.
Data Structures | |
struct | ast_fdset |
Defines | |
#define | _bitsize(a) (sizeof(a) * 8) |
#define | ast_FDMAX 32768 |
#define | FD_SET(fd, fds) |
#define | FD_ZERO(a) |
Functions | |
static int | ast_select (int nfds, ast_fdset *rfds, ast_fdset *wfds, ast_fdset *efds, struct timeval *tvp) |
Waits for activity on a group of channels. | |
Variables | |
unsigned int | ast_FD_SETSIZE |
Definition in file select.h.
#define FD_SET | ( | fd, | |||
fds | ) |
#define FD_ZERO | ( | a | ) |
static int ast_select | ( | int | nfds, | |
ast_fdset * | rfds, | |||
ast_fdset * | wfds, | |||
ast_fdset * | efds, | |||
struct timeval * | tvp | |||
) | [inline, static] |
Waits for activity on a group of channels.
nfds | the maximum number of file descriptors in the sets | |
rfds | file descriptors to check for read availability | |
wfds | file descriptors to check for write availability | |
efds | file descriptors to check for exceptions (OOB data) | |
tvp | timeout while waiting for events This is the same as a standard select(), except it guarantees the behaviour where the passed struct timeval is updated with how much time was not slept while waiting for the specified events |
Definition at line 81 of file select.h.
References errno, and timersub().
Referenced by ast_poll2(), and main().
00082 { 00083 #ifdef __linux__ 00084 return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp); 00085 #else 00086 int save_errno = 0; 00087 if (tvp) { 00088 struct timeval tv, tvstart, tvend, tvlen; 00089 int res; 00090 00091 tv = *tvp; 00092 gettimeofday(&tvstart, NULL); 00093 res = select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp); 00094 save_errno = errno; 00095 gettimeofday(&tvend, NULL); 00096 timersub(&tvend, &tvstart, &tvlen); 00097 timersub(&tv, &tvlen, tvp); 00098 if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) { 00099 tvp->tv_sec = 0; 00100 tvp->tv_usec = 0; 00101 } 00102 errno = save_errno; 00103 return res; 00104 } 00105 else 00106 return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, NULL); 00107 #endif 00108 }
unsigned int ast_FD_SETSIZE |