]> granicus.if.org Git - apache/blob - server/mpm_fdqueue.h
request: forward as much buckets as possible in ap_request_core_filter().
[apache] / server / mpm_fdqueue.h
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 /**
18  * @file  server/mpm_fdqueue.h
19  * @brief fd queue declarations
20  *
21  * @addtogroup APACHE_MPM_EVENT
22  * @{
23  */
24
25 #ifndef MPM_FDQUEUE_H
26 #define MPM_FDQUEUE_H
27
28 #include <apr.h>
29
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...
32  */
33 #if APR_HAS_THREADS
34
35 #include "ap_mpm.h"
36
37 #include <apr_ring.h>
38 #include <apr_pools.h>
39 #include <apr_thread_mutex.h>
40 #include <apr_thread_cond.h>
41 #include <apr_network_io.h>
42
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;
47
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,
55                                                       int *had_to_block);
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);
58
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);
64
65 struct timer_event_t
66 {
67     APR_RING_ENTRY(timer_event_t) link;
68     apr_time_t when;
69     ap_mpm_callback_fn_t *cbfunc;
70     void *baton;
71     int canceled;
72     apr_array_header_t *remove;
73 };
74 typedef struct timer_event_t timer_event_t;
75
76 struct fd_queue_t
77 {
78     APR_RING_HEAD(timers_t, timer_event_t) timers;
79     fd_queue_elem_t *data;
80     unsigned int nelts;
81     unsigned int bounds;
82     unsigned int in;
83     unsigned int out;
84     apr_thread_mutex_t *one_big_mutex;
85     apr_thread_cond_t *not_empty;
86     int terminated;
87 };
88 typedef struct fd_queue_t fd_queue_t;
89
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,
94                                               apr_pool_t *p);
95 AP_DECLARE(apr_status_t) ap_queue_push_timer(fd_queue_t *queue,
96                                              timer_event_t *te);
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)
102
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);
106
107 #endif /* APR_HAS_THREADS */
108
109 #endif /* MPM_FDQUEUE_H */
110 /** @} */