842ae4bd224140319ae7feec1872b93dfd491143fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding * contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding * this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding * The ASF licenses this file to You under the Apache License, Version 2.0
842ae4bd224140319ae7feec1872b93dfd491143fielding * (the "License"); you may not use this file except in compliance with
842ae4bd224140319ae7feec1872b93dfd491143fielding * the License. You may obtain a copy of the License at
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * http://www.apache.org/licenses/LICENSE-2.0
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * limitations under the License.
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb */
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh/**
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @file worker/fdqueue.h
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @brief fd queue declarations
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh *
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @addtogroup APACHE_MPM_WORKER
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @{
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh */
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#ifndef FDQUEUE_H
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#define FDQUEUE_H
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#include "httpd.h"
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#include <stdlib.h>
fe46444c8f32f00d040ebefa94bcd0c05ab15ab9martin#if APR_HAVE_UNISTD_H
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#include <unistd.h>
fe46444c8f32f00d040ebefa94bcd0c05ab15ab9martin#endif
64ff1949093e64474a00badd61a3495e35fa192daaron#include <apr_thread_mutex.h>
64ff1949093e64474a00badd61a3495e35fa192daaron#include <apr_thread_cond.h>
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#include <sys/types.h>
52fc962d27921f20981eef91d6236e9024c604d7wrowe#if APR_HAVE_SYS_SOCKET_H
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#include <sys/socket.h>
52fc962d27921f20981eef91d6236e9024c604d7wrowe#endif
e00ae6859667e293a4c40108f524408ae1289f2frbb#include <apr_errno.h>
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb
7d37dff338a52aa8836d78e4f1a67b76911da66caarontypedef struct fd_queue_info_t fd_queue_info_t;
7d37dff338a52aa8836d78e4f1a67b76911da66caaron
7d37dff338a52aa8836d78e4f1a67b76911da66caaronapr_status_t ap_queue_info_create(fd_queue_info_t **queue_info,
5d5d5ca04c57c7ab865924f4648e8f80de27adfebrianp apr_pool_t *pool, int max_idlers);
5d5d5ca04c57c7ab865924f4648e8f80de27adfebrianpapr_status_t ap_queue_info_set_idle(fd_queue_info_t *queue_info,
5d5d5ca04c57c7ab865924f4648e8f80de27adfebrianp apr_pool_t *pool_to_recycle);
5d5d5ca04c57c7ab865924f4648e8f80de27adfebrianpapr_status_t ap_queue_info_wait_for_idler(fd_queue_info_t *queue_info,
5d5d5ca04c57c7ab865924f4648e8f80de27adfebrianp apr_pool_t **recycled_pool);
7d37dff338a52aa8836d78e4f1a67b76911da66caaronapr_status_t ap_queue_info_term(fd_queue_info_t *queue_info);
7d37dff338a52aa8836d78e4f1a67b76911da66caaron
e00ae6859667e293a4c40108f524408ae1289f2frbbstruct fd_queue_elem_t {
e00ae6859667e293a4c40108f524408ae1289f2frbb apr_socket_t *sd;
e00ae6859667e293a4c40108f524408ae1289f2frbb apr_pool_t *p;
e00ae6859667e293a4c40108f524408ae1289f2frbb};
e00ae6859667e293a4c40108f524408ae1289f2frbbtypedef struct fd_queue_elem_t fd_queue_elem_t;
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb
e00ae6859667e293a4c40108f524408ae1289f2frbbstruct fd_queue_t {
64ff1949093e64474a00badd61a3495e35fa192daaron fd_queue_elem_t *data;
8639a789ef8a4adec121d5b26b4d66c5cf8989ccjim unsigned int nelts;
8639a789ef8a4adec121d5b26b4d66c5cf8989ccjim unsigned int bounds;
8639a789ef8a4adec121d5b26b4d66c5cf8989ccjim unsigned int in;
8639a789ef8a4adec121d5b26b4d66c5cf8989ccjim unsigned int out;
64ff1949093e64474a00badd61a3495e35fa192daaron apr_thread_mutex_t *one_big_mutex;
64ff1949093e64474a00badd61a3495e35fa192daaron apr_thread_cond_t *not_empty;
6a5bdbbacf4a62adecde52b8f23ebcc4fa2a08b8trawick int terminated;
e00ae6859667e293a4c40108f524408ae1289f2frbb};
e00ae6859667e293a4c40108f524408ae1289f2frbbtypedef struct fd_queue_t fd_queue_t;
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb
a322a82f79b790fb7ddcd7df4459d20725450fa7trawickapr_status_t ap_queue_init(fd_queue_t *queue, int queue_capacity, apr_pool_t *a);
5d5d5ca04c57c7ab865924f4648e8f80de27adfebrianpapr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p);
5d5d5ca04c57c7ab865924f4648e8f80de27adfebrianpapr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p);
e00ae6859667e293a4c40108f524408ae1289f2frbbapr_status_t ap_queue_interrupt_all(fd_queue_t *queue);
6a5bdbbacf4a62adecde52b8f23ebcc4fa2a08b8trawickapr_status_t ap_queue_term(fd_queue_t *queue);
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb
b1627fe7e2cb3809dcdfdf1fcbbb6dbccaf788c6rbb#endif /* FDQUEUE_H */
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh/** @} */