Apache HTTPD
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#elif HAVE_SYS_POLL_H
23#include <sys/poll.h>
24#endif
25
26#ifdef HAVE_PORT_CREATE
27#include <port.h>
28#include <sys/port_impl.h>
29#endif
30
31#ifdef HAVE_KQUEUE
32#include <sys/types.h>
33#include <sys/event.h>
34#include <sys/time.h>
35#endif
36
37#ifdef HAVE_EPOLL
38#include <sys/epoll.h>
39#endif
40
41#ifdef NETWARE
42#define HAS_SOCKETS(dt) (dt == APR_POLL_SOCKET) ? 1 : 0
43#define HAS_PIPES(dt) (dt == APR_POLL_FILE) ? 1 : 0
44#endif
45
46#if defined(HAVE_AIO_H) && defined(HAVE_AIO_MSGQ)
47#define _AIO_OS390 /* enable a bunch of z/OS aio.h definitions */
48#include <aio.h> /* aiocb */
49#endif
50
51/* Choose the best method platform specific to use in apr_pollset */
52#ifdef HAVE_KQUEUE
53#define POLLSET_USES_KQUEUE
54#define POLLSET_DEFAULT_METHOD APR_POLLSET_KQUEUE
55#elif defined(HAVE_PORT_CREATE)
56#define POLLSET_USES_PORT
57#define POLLSET_DEFAULT_METHOD APR_POLLSET_PORT
58#elif defined(HAVE_EPOLL)
59#define POLLSET_USES_EPOLL
60#define POLLSET_DEFAULT_METHOD APR_POLLSET_EPOLL
61#elif defined(HAVE_AIO_MSGQ)
62#define POLLSET_USES_AIO_MSGQ
63#define POLLSET_DEFAULT_METHOD APR_POLLSET_AIO_MSGQ
64#elif defined(HAVE_POLL)
65#define POLLSET_USES_POLL
66#define POLLSET_DEFAULT_METHOD APR_POLLSET_POLL
67#else
68#define POLLSET_USES_SELECT
69#define POLLSET_DEFAULT_METHOD APR_POLLSET_SELECT
70#endif
71
72#ifdef WIN32
73#define POLL_USES_SELECT
74#undef POLLSET_DEFAULT_METHOD
75#define POLLSET_DEFAULT_METHOD APR_POLLSET_SELECT
76#else
77#ifdef HAVE_POLL
78#define POLL_USES_POLL
79#else
80#define POLL_USES_SELECT
81#endif
82#endif
83
84#if defined(POLLSET_USES_KQUEUE) || defined(POLLSET_USES_EPOLL) || defined(POLLSET_USES_PORT) || defined(POLLSET_USES_AIO_MSGQ)
85
86#include "apr_ring.h"
87
88#if APR_HAS_THREADS
89#include "apr_thread_mutex.h"
90#define pollset_lock_rings() \
91 if (pollset->flags & APR_POLLSET_THREADSAFE) \
92 apr_thread_mutex_lock(pollset->p->ring_lock);
93#define pollset_unlock_rings() \
94 if (pollset->flags & APR_POLLSET_THREADSAFE) \
95 apr_thread_mutex_unlock(pollset->p->ring_lock);
96#else
97#define pollset_lock_rings()
98#define pollset_unlock_rings()
99#endif
100
101typedef struct pfd_elem_t pfd_elem_t;
102
103struct pfd_elem_t {
105 apr_pollfd_t pfd;
106#ifdef HAVE_PORT_CREATE
107 int on_query_ring;
108#endif
109};
110
111#endif
112
116
129
130typedef union {
131#if defined(HAVE_EPOLL)
132 struct epoll_event *epoll;
133#endif
134#if defined(HAVE_PORT_CREATE)
136#endif
137#if defined(HAVE_KQUEUE)
138 struct kevent *ke;
139#endif
140#if defined(HAVE_POLL)
141 struct pollfd *ps;
142#endif
143 void *undef;
145
159
168
177
178/*
179 * Private functions used for the implementation of both apr_pollcb_* and
180 * apr_pollset_*
181 */
183 apr_file_t **wakeup_pipe);
185void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe);
186
187#endif /* APR_ARCH_POLL_PRIVATE_H */
apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd, apr_file_t **wakeup_pipe)
void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe)
Definition wakeup.c:138
apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe)
Definition wakeup.c:69
APR Rings.
APR Thread Mutex Routines.
const char server_rec server_rec ** ps
const char apr_port_t port
Definition http_vhost.h:125
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
int apr_status_t
Definition apr_errno.h:44
apr_status_t(* apr_pollcb_cb_t)(void *baton, apr_pollfd_t *descriptor)
Definition apr_poll.h:401
#define APR_RING_ENTRY(elem)
Definition apr_ring.h:70
apr_int64_t apr_interval_time_t
Definition apr_time.h:55
apr_status_t(* remove)(apr_pollcb_t *, apr_pollfd_t *)
apr_status_t(* create)(apr_pollcb_t *, apr_uint32_t, apr_pool_t *, apr_uint32_t)
apr_status_t(* poll)(apr_pollcb_t *, apr_interval_time_t, apr_pollcb_cb_t, void *)
apr_status_t(* cleanup)(apr_pollcb_t *)
apr_status_t(* add)(apr_pollcb_t *, apr_pollfd_t *)
apr_file_t * wakeup_pipe[2]
apr_pollfd_t wakeup_pfd
const apr_pollcb_provider_t * provider
apr_pollcb_pset pollset
apr_pollfd_t ** copyset
apr_status_t(* add)(apr_pollset_t *, const apr_pollfd_t *)
apr_status_t(* poll)(apr_pollset_t *, apr_interval_time_t, apr_int32_t *, const apr_pollfd_t **)
apr_status_t(* cleanup)(apr_pollset_t *)
apr_status_t(* remove)(apr_pollset_t *, const apr_pollfd_t *)
apr_status_t(* create)(apr_pollset_t *, apr_uint32_t, apr_pool_t *, apr_uint32_t)
apr_file_t * wakeup_pipe[2]
const apr_pollset_provider_t * provider
apr_pollset_private_t * p