Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Poll Routines
[Brought To You By APR]


Defines

#define SWITCH_POLLIN   0x001
#define SWITCH_POLLPRI   0x002
#define SWITCH_POLLOUT   0x004
#define SWITCH_POLLERR   0x010
#define SWITCH_POLLHUP   0x020
#define SWITCH_POLLNVAL   0x040

Typedefs

typedef apr_pollfd_t switch_pollfd_t
typedef apr_pollset_t switch_pollset_t

Functions

switch_status_t switch_pollset_create (switch_pollset_t **pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags)
switch_status_t switch_pollset_add (switch_pollset_t *pollset, const switch_pollfd_t *descriptor)
switch_status_t switch_poll (switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout)
switch_status_t switch_socket_create_pollfd (switch_pollfd_t **poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool)
 Create a set of file descriptors to poll.
switch_status_t switch_match_glob (const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p)
switch_status_t switch_socket_addr_get (switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock)


Define Documentation

#define SWITCH_POLLERR   0x010
 

Pending error

#define SWITCH_POLLHUP   0x020
 

Hangup occurred

#define SWITCH_POLLIN   0x001
 

Can read without blocking

#define SWITCH_POLLNVAL   0x040
 

Descriptior invalid

#define SWITCH_POLLOUT   0x004
 

Can write without blocking

#define SWITCH_POLLPRI   0x002
 

Priority data available


Typedef Documentation

typedef struct apr_pollfd_t switch_pollfd_t
 

Poll descriptor set.

typedef struct apr_pollset_t switch_pollset_t
 

Opaque structure used for pollset API


Function Documentation

switch_status_t switch_match_glob const char *  pattern,
switch_array_header_t **  result,
switch_memory_pool_t p
 

00840 {
00841         return apr_match_glob(pattern, (apr_array_header_t **) result, p);
00842 }

switch_status_t switch_poll switch_pollfd_t aprset,
int32_t  numsock,
int32_t *  nsds,
switch_interval_time_t  timeout
 

Poll the sockets in the poll structure

Parameters:
aprset The poll structure we will be using.
numsock The number of sockets we are polling
nsds The number of sockets signalled.
timeout The amount of time in microseconds to wait. This is a maximum, not a minimum. If a socket is signalled, we will wake up before this time. A negative number means wait until a socket is signalled.
Remarks:
The number of sockets signalled is returned in the third argument. This is a blocking call, and it will not return until either a socket has been signalled, or the timeout has expired.
00707 {
00708         return apr_poll(aprset, numsock, nsds, timeout);
00709 }

switch_status_t switch_pollset_add switch_pollset_t pollset,
const switch_pollfd_t descriptor
 

Add a socket or file descriptor to a pollset

Parameters:
pollset The pollset to which to add the descriptor
descriptor The descriptor to add
Remarks:
If you set client_data in the descriptor, that value will be returned in the client_data field whenever this descriptor is signalled in apr_pollset_poll().

If the pollset has been created with APR_POLLSET_THREADSAFE and thread T1 is blocked in a call to apr_pollset_poll() for this same pollset that is being modified via apr_pollset_add() in thread T2, the currently executing apr_pollset_poll() call in T1 will either: (1) automatically include the newly added descriptor in the set of descriptors it is watching or (2) return immediately with APR_EINTR. Option (1) is recommended, but option (2) is allowed for implementations where option (1) is impossible or impractical.

00702 {
00703         return apr_pollset_add(pollset, descriptor);
00704 }

switch_status_t switch_pollset_create switch_pollset_t **  pollset,
uint32_t  size,
switch_memory_pool_t p,
uint32_t  flags
 

Setup a pollset object

Parameters:
pollset The pointer in which to return the newly created object
size The maximum number of descriptors that this pollset can hold
p The pool from which to allocate the pollset
flags Optional flags to modify the operation of the pollset.
Remarks:
If flags equals APR_POLLSET_THREADSAFE, then a pollset is created on which it is safe to make concurrent calls to apr_pollset_add(), apr_pollset_remove() and apr_pollset_poll() from separate threads. This feature is only supported on some platforms; the apr_pollset_create() call will fail with APR_ENOTIMPL on platforms where it is not supported.
00697 {
00698         return apr_pollset_create(pollset, size, p, flags);
00699 }

switch_status_t switch_socket_addr_get switch_sockaddr_t **  sa,
switch_bool_t  remote,
switch_socket_t sock
 

00552 {
00553         return apr_socket_addr_get(sa, remote, sock);
00554 }

switch_status_t switch_socket_create_pollfd switch_pollfd_t **  poll,
switch_socket_t sock,
int16_t  flags,
switch_memory_pool_t pool
 

Create a set of file descriptors to poll.

Parameters:
poll the polfd to create
sock the socket to add
flags the flags to modify the behaviour
pool the memory pool to use
Returns:
SWITCH_STATUS_SUCCESS when successful
00712 {
00713         switch_pollset_t *pollset;
00714 
00715         void *ptr = NULL;
00716 
00717         if ((ptr = apr_palloc(pool, sizeof(switch_pollfd_t))) == 0) {
00718                 return SWITCH_STATUS_MEMERR;
00719         }
00720 
00721         if (switch_pollset_create(&pollset, 1, pool, flags) != SWITCH_STATUS_SUCCESS) {
00722                 return SWITCH_STATUS_GENERR;
00723         }
00724 
00725         memset(ptr, 0, sizeof(switch_pollfd_t));
00726         *poll = ptr;
00727 
00728         (*poll)->desc_type = APR_POLL_SOCKET;
00729         (*poll)->reqevents = flags;
00730         (*poll)->desc.s = sock;
00731         (*poll)->client_data = sock;
00732 
00733         if (switch_pollset_add(pollset, *poll) != SWITCH_STATUS_SUCCESS) {
00734                 return SWITCH_STATUS_GENERR;
00735         }
00736 
00737         return SWITCH_STATUS_SUCCESS;
00738 }

Here is the call graph for this function:


Generated on Fri Oct 10 11:24:23 2008 for FreeSWITCH by  doxygen 1.3.9.1