Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apr_arch_poll_private.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef APR_ARCH_POLL_PRIVATE_H
18 #define APR_ARCH_POLL_PRIVATE_H
19 
20 #if HAVE_POLL_H
21 #include <poll.h>
22 #endif
23 
24 #if HAVE_SYS_POLL_H
25 #include <sys/poll.h>
26 #endif
27 
28 #ifdef HAVE_PORT_CREATE
29 #include <port.h>
30 #include <sys/port_impl.h>
31 #endif
32 
33 #ifdef HAVE_KQUEUE
34 #include <sys/types.h>
35 #include <sys/event.h>
36 #include <sys/time.h>
37 #endif
38 
39 #ifdef HAVE_EPOLL
40 #include <sys/epoll.h>
41 #endif
42 
43 #ifdef NETWARE
44 #define HAS_SOCKETS(dt) (dt == APR_POLL_SOCKET) ? 1 : 0
45 #define HAS_PIPES(dt) (dt == APR_POLL_FILE) ? 1 : 0
46 #endif
47 
48 #if defined(HAVE_AIO_H) && defined(HAVE_AIO_MSGQ)
49 #define _AIO_OS390 /* enable a bunch of z/OS aio.h definitions */
50 #include <aio.h> /* aiocb */
51 #endif
52 
53 /* Choose the best method platform specific to use in apr_pollset */
54 #ifdef HAVE_KQUEUE
55 #define POLLSET_USES_KQUEUE
56 #define POLLSET_DEFAULT_METHOD APR_POLLSET_KQUEUE
57 #elif defined(HAVE_PORT_CREATE)
58 #define POLLSET_USES_PORT
59 #define POLLSET_DEFAULT_METHOD APR_POLLSET_PORT
60 #elif defined(HAVE_EPOLL)
61 #define POLLSET_USES_EPOLL
62 #define POLLSET_DEFAULT_METHOD APR_POLLSET_EPOLL
63 #elif defined(HAVE_AIO_MSGQ)
64 #define POLLSET_USES_AIO_MSGQ
65 #define POLLSET_DEFAULT_METHOD APR_POLLSET_AIO_MSGQ
66 #elif defined(HAVE_POLL)
67 #define POLLSET_USES_POLL
68 #define POLLSET_DEFAULT_METHOD APR_POLLSET_POLL
69 #else
70 #define POLLSET_USES_SELECT
71 #define POLLSET_DEFAULT_METHOD APR_POLLSET_SELECT
72 #endif
73 
74 #ifdef WIN32
75 #define POLL_USES_SELECT
76 #undef POLLSET_DEFAULT_METHOD
77 #define POLLSET_DEFAULT_METHOD APR_POLLSET_SELECT
78 #else
79 #ifdef HAVE_POLL
80 #define POLL_USES_POLL
81 #else
82 #define POLL_USES_SELECT
83 #endif
84 #endif
85 
86 #if defined(POLLSET_USES_KQUEUE) || defined(POLLSET_USES_EPOLL) || defined(POLLSET_USES_PORT) || defined(POLLSET_USES_AIO_MSGQ)
87 
88 #include "apr_ring.h"
89 
90 #if APR_HAS_THREADS
91 #include "apr_thread_mutex.h"
92 #define pollset_lock_rings() \
93  if (pollset->flags & APR_POLLSET_THREADSAFE) \
94  apr_thread_mutex_lock(pollset->p->ring_lock);
95 #define pollset_unlock_rings() \
96  if (pollset->flags & APR_POLLSET_THREADSAFE) \
97  apr_thread_mutex_unlock(pollset->p->ring_lock);
98 #else
99 #define pollset_lock_rings()
100 #define pollset_unlock_rings()
101 #endif
102 
103 typedef struct pfd_elem_t pfd_elem_t;
104 
105 struct pfd_elem_t {
106  APR_RING_ENTRY(pfd_elem_t) link;
107  apr_pollfd_t pfd;
108 #ifdef HAVE_PORT_CREATE
109  int on_query_ring;
110 #endif
111 };
112 
113 #endif
114 
118 
120 {
125  /* Pipe descriptors used for wakeup */
130 };
131 
132 typedef union {
133 #if defined(HAVE_EPOLL)
134  struct epoll_event *epoll;
135 #endif
136 #if defined(HAVE_PORT_CREATE)
137  port_event_t *port;
138 #endif
139 #if defined(HAVE_KQUEUE)
140  struct kevent *ke;
141 #endif
142 #if defined(HAVE_POLL)
143  struct pollfd *ps;
144 #endif
145  void *undef;
147 
148 struct apr_pollcb_t {
153  /* Pipe descriptors used for wakeup */
156  int fd;
160 };
161 
165  apr_status_t (*remove)(apr_pollset_t *, const apr_pollfd_t *);
168  const char *name;
169 };
170 
177  const char *name;
178 };
179 
180 /*
181  * Private functions used for the implementation of both apr_pollcb_* and
182  * apr_pollset_*
183  */
185  apr_file_t **wakeup_pipe);
187 void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe);
188 
189 #endif /* APR_ARCH_POLL_PRIVATE_H */
apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe)
apr_pollfd_t wakeup_pfd
Definition: apr_arch_poll_private.h:127
const char * name
Definition: apr_arch_poll_private.h:168
Definition: apr_arch_file_io.h:107
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
apr_pollfd_t ** copyset
Definition: apr_arch_poll_private.h:158
void * undef
Definition: apr_arch_poll_private.h:145
apr_status_t(* create)(apr_pollcb_t *, apr_uint32_t, apr_pool_t *, apr_uint32_t)
Definition: apr_arch_poll_private.h:172
apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd, apr_file_t **wakeup_pipe)
apr_uint32_t nalloc
Definition: apr_arch_poll_private.h:151
apr_pool_t * pool
Definition: apr_arch_poll_private.h:121
struct apr_pollset_private_t apr_pollset_private_t
Definition: apr_arch_poll_private.h:115
apr_status_t(* add)(apr_pollset_t *, const apr_pollfd_t *)
Definition: apr_arch_poll_private.h:164
APR Thread Mutex Routines.
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
apr_file_t * wakeup_pipe[2]
Definition: apr_arch_poll_private.h:154
apr_status_t(* apr_pollcb_cb_t)(void *baton, apr_pollfd_t *descriptor)
Definition: apr_poll.h:410
apr_status_t(* poll)(apr_pollset_t *, apr_interval_time_t, apr_int32_t *, const apr_pollfd_t **)
Definition: apr_arch_poll_private.h:166
apr_pool_t * pool
Definition: apr_arch_poll_private.h:149
Definition: apr_poll.h:117
apr_status_t(* cleanup)(apr_pollcb_t *)
Definition: apr_arch_poll_private.h:176
apr_status_t(* add)(apr_pollcb_t *, apr_pollfd_t *)
Definition: apr_arch_poll_private.h:173
Definition: apr_arch_poll_private.h:148
unsigned int apr_uint32_t
Definition: apr.h:334
Definition: apr_arch_misc.h:357
apr_status_t(* poll)(apr_pollcb_t *, apr_interval_time_t, apr_pollcb_cb_t, void *)
Definition: apr_arch_poll_private.h:175
apr_uint32_t nelts
Definition: apr_arch_poll_private.h:122
int fd
Definition: apr_arch_poll_private.h:156
apr_uint32_t nelts
Definition: apr_arch_poll_private.h:150
apr_status_t(* cleanup)(apr_pollset_t *)
Definition: apr_arch_poll_private.h:167
Definition: apr_arch_poll_private.h:171
apr_file_t * wakeup_pipe[2]
Definition: apr_arch_poll_private.h:126
Definition: apr_arch_poll_private.h:132
Definition: apr_arch_poll_private.h:162
apr_uint32_t flags
Definition: apr_arch_poll_private.h:152
void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe)
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
const apr_pollset_provider_t * provider
Definition: apr_arch_poll_private.h:129
int apr_status_t
Definition: apr_errno.h:44
apr_uint32_t nalloc
Definition: apr_arch_poll_private.h:123
apr_pollset_private_t * p
Definition: apr_arch_poll_private.h:128
#define APR_RING_ENTRY(elem)
Definition: apr_ring.h:70
apr_pollfd_t wakeup_pfd
Definition: apr_arch_poll_private.h:155
apr_uint32_t flags
Definition: apr_arch_poll_private.h:124
apr_pollcb_pset pollset
Definition: apr_arch_poll_private.h:157
apr_status_t(* create)(apr_pollset_t *, apr_uint32_t, apr_pool_t *, apr_uint32_t)
Definition: apr_arch_poll_private.h:163
const char * name
Definition: apr_arch_poll_private.h:177
APR Rings.
const apr_pollcb_provider_t * provider
Definition: apr_arch_poll_private.h:159
int apr_int32_t
Definition: apr.h:333
Definition: apr_arch_poll_private.h:119