fdqueue.h revision e7c42c26f9d1f8bfdc703028801bb3daff2f982a
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder/* ====================================================================
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * The Apache Software License, Version 1.1
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens Elkner *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * reserved.
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Redistribution and use in source and binary forms, with or without
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * modification, are permitted provided that the following conditions
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * are met:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 1. Redistributions of source code must retain the above copyright
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * notice, this list of conditions and the following disclaimer.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 2. Redistributions in binary form must reproduce the above copyright
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * notice, this list of conditions and the following disclaimer in
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * the documentation and/or other materials provided with the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * distribution.
654eedbcf7478c0d24ecba13325cf57ac2858071Christian Maeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 3. The end-user documentation included with the redistribution,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * if any, must include the following acknowledgment:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * "This product includes software developed by the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Apache Software Foundation (http://www.apache.org/)."
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Alternately, this acknowledgment may appear in the software itself,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * if and wherever such third-party acknowledgments normally appear.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 4. The names "Apache" and "Apache Software Foundation" must
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * not be used to endorse or promote products derived from this
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * software without prior written permission. For written
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * permission, please contact apache@apache.org.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 5. Products derived from this software may not be called "Apache",
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * nor may "Apache" appear in their name, without prior written
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * permission of the Apache Software Foundation.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * SUCH DAMAGE.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * ====================================================================
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder * This software consists of voluntary contributions made by many
ba06b25b69be05a4733db7197940efd73976f215Jonathan von Schroeder * individuals on behalf of the Apache Software Foundation. For more
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * information on the Apache Software Foundation, please see
ba06b25b69be05a4733db7197940efd73976f215Jonathan von Schroeder * <http://www.apache.org/>.
ba06b25b69be05a4733db7197940efd73976f215Jonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Portions of this software are based upon public domain software
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * originally written at the National Center for Supercomputing Applications,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * University of Illinois, Urbana-Champaign.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder */
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#ifndef FDQUEUE_H
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#define FDQUEUE_H
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#include "httpd.h"
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#include <stdlib.h>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#if APR_HAVE_UNISTD_H
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#include <unistd.h>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#endif
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#include <apr_thread_mutex.h>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#include <apr_thread_cond.h>
656f17ae9b7610ff2de1b6eedeeadea0c3bcdc8dChristian Maeder#include <sys/types.h>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#if APR_HAVE_SYS_SOCKET_H
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#include <sys/socket.h>
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#endif
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder#include <apr_errno.h>
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
ba06b25b69be05a4733db7197940efd73976f215Jonathan von Schroederstruct fd_queue_elem_t {
ba06b25b69be05a4733db7197940efd73976f215Jonathan von Schroeder apr_socket_t *sd;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder apr_pool_t *p;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder};
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroedertypedef struct fd_queue_elem_t fd_queue_elem_t;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederstruct fd_queue_t {
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder int head;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder int tail;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder fd_queue_elem_t *data;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder int nelts;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder int bounds;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder apr_thread_mutex_t *one_big_mutex;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder apr_thread_cond_t *not_empty;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder apr_thread_cond_t *not_full;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder apr_pool_t **recycled_pools;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder int num_recycled;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder int terminated;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder};
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroedertypedef struct fd_queue_t fd_queue_t;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederapr_status_t ap_queue_init(fd_queue_t *queue, int queue_capacity, apr_pool_t *a);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederapr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder apr_pool_t **recycled_pool);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederapr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder apr_pool_t *recycled_pool);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederapr_status_t ap_queue_interrupt_all(fd_queue_t *queue);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederapr_status_t ap_queue_term(fd_queue_t *queue);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#endif /* FDQUEUE_H */
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder