]> granicus.if.org Git - apache/blob - server/mpm/experimental/event/fdqueue.h
Update the copyright year in all .c, .h and .xml files
[apache] / server / mpm / experimental / event / fdqueue.h
1 /* Copyright 2001-2006 The Apache Software Foundation or its licensors, as
2  * applicable.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * 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  event/fdqueue.h
19  * @brief fd queue declarations
20  *
21  * @addtogroup APACHE_MPM_EVENT
22  * @{
23  */
24
25 #ifndef FDQUEUE_H
26 #define FDQUEUE_H
27 #include "httpd.h"
28 #include <stdlib.h>
29 #if APR_HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32 #include <apr_thread_mutex.h>
33 #include <apr_thread_cond.h>
34 #include <sys/types.h>
35 #if APR_HAVE_SYS_SOCKET_H
36 #include <sys/socket.h>
37 #endif
38 #include <apr_errno.h>
39
40 typedef struct fd_queue_info_t fd_queue_info_t;
41
42 apr_status_t ap_queue_info_create(fd_queue_info_t ** queue_info,
43                                   apr_pool_t * pool, int max_idlers);
44 apr_status_t ap_queue_info_set_idle(fd_queue_info_t * queue_info,
45                                     apr_pool_t * pool_to_recycle);
46 apr_status_t ap_queue_info_wait_for_idler(fd_queue_info_t * queue_info);
47 apr_status_t ap_queue_info_term(fd_queue_info_t * queue_info);
48
49 struct fd_queue_elem_t
50 {
51     apr_socket_t *sd;
52     apr_pool_t *p;
53     conn_state_t *cs;
54 };
55 typedef struct fd_queue_elem_t fd_queue_elem_t;
56
57 struct fd_queue_t
58 {
59     fd_queue_elem_t *data;
60     int nelts;
61     int bounds;
62     apr_thread_mutex_t *one_big_mutex;
63     apr_thread_cond_t *not_empty;
64     int terminated;
65 };
66 typedef struct fd_queue_t fd_queue_t;
67
68 void ap_pop_pool(apr_pool_t ** recycled_pool, fd_queue_info_t * queue_info);
69 void ap_push_pool(fd_queue_info_t * queue_info,          
70                                     apr_pool_t * pool_to_recycle);
71
72 apr_status_t ap_queue_init(fd_queue_t * queue, int queue_capacity,
73                            apr_pool_t * a);
74 apr_status_t ap_queue_push(fd_queue_t * queue, apr_socket_t * sd,
75                            conn_state_t * cs, apr_pool_t * p);
76 apr_status_t ap_queue_pop(fd_queue_t * queue, apr_socket_t ** sd,
77                           conn_state_t ** cs, apr_pool_t ** p);
78 apr_status_t ap_queue_interrupt_all(fd_queue_t * queue);
79 apr_status_t ap_queue_term(fd_queue_t * queue);
80
81 #endif /* FDQUEUE_H */
82 /** @} */