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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file server/mpm_fdqueue.h
19 * @brief fd queue declarations
21 * @addtogroup APACHE_MPM_EVENT
30 /* This code is not AP_DECLARE()ed/exported, and used by MPMs event/worker
31 * only (for now), not worth thinking about w/o threads either...
38 #include <apr_pools.h>
39 #include <apr_thread_mutex.h>
40 #include <apr_thread_cond.h>
41 #include <apr_network_io.h>
43 struct fd_queue_info_t; /* opaque */
44 struct fd_queue_elem_t; /* opaque */
45 typedef struct fd_queue_info_t fd_queue_info_t;
46 typedef struct fd_queue_elem_t fd_queue_elem_t;
48 AP_DECLARE(apr_status_t) ap_queue_info_create(fd_queue_info_t **queue_info,
49 apr_pool_t *pool, int max_idlers,
50 int max_recycled_pools);
51 AP_DECLARE(apr_status_t) ap_queue_info_set_idle(fd_queue_info_t *queue_info,
52 apr_pool_t *pool_to_recycle);
53 AP_DECLARE(apr_status_t) ap_queue_info_try_get_idler(fd_queue_info_t *queue_info);
54 AP_DECLARE(apr_status_t) ap_queue_info_wait_for_idler(fd_queue_info_t *queue_info,
56 AP_DECLARE(apr_uint32_t) ap_queue_info_num_idlers(fd_queue_info_t *queue_info);
57 AP_DECLARE(apr_status_t) ap_queue_info_term(fd_queue_info_t *queue_info);
59 AP_DECLARE(void) ap_queue_info_pop_pool(fd_queue_info_t *queue_info,
60 apr_pool_t **recycled_pool);
61 AP_DECLARE(void) ap_queue_info_push_pool(fd_queue_info_t *queue_info,
62 apr_pool_t *pool_to_recycle);
63 AP_DECLARE(void) ap_queue_info_free_idle_pools(fd_queue_info_t *queue_info);
67 APR_RING_ENTRY(timer_event_t) link;
69 ap_mpm_callback_fn_t *cbfunc;
72 apr_array_header_t *remove;
74 typedef struct timer_event_t timer_event_t;
78 APR_RING_HEAD(timers_t, timer_event_t) timers;
79 fd_queue_elem_t *data;
84 apr_thread_mutex_t *one_big_mutex;
85 apr_thread_cond_t *not_empty;
88 typedef struct fd_queue_t fd_queue_t;
90 AP_DECLARE(apr_status_t) ap_queue_create(fd_queue_t **pqueue,
91 int capacity, apr_pool_t *p);
92 AP_DECLARE(apr_status_t) ap_queue_push_socket(fd_queue_t *queue,
93 apr_socket_t *sd, void *sd_baton,
95 AP_DECLARE(apr_status_t) ap_queue_push_timer(fd_queue_t *queue,
97 AP_DECLARE(apr_status_t) ap_queue_pop_something(fd_queue_t *queue,
98 apr_socket_t **sd, void **sd_baton,
99 apr_pool_t **p, timer_event_t **te);
100 #define ap_queue_pop_socket(q_, s_, p_) \
101 ap_queue_pop_something((q_), (s_), NULL, (p_), NULL)
103 AP_DECLARE(apr_status_t) ap_queue_interrupt_all(fd_queue_t *queue);
104 AP_DECLARE(apr_status_t) ap_queue_interrupt_one(fd_queue_t *queue);
105 AP_DECLARE(apr_status_t) ap_queue_term(fd_queue_t *queue);
107 #endif /* APR_HAS_THREADS */
109 #endif /* MPM_FDQUEUE_H */