|
Apache HTTPD
|
#include "apr.h"#include "apr_portable.h"#include "apr_strings.h"#include "apr_file_io.h"#include "apr_thread_proc.h"#include "apr_signal.h"#include "apr_thread_mutex.h"#include "apr_poll.h"#include "apr_ring.h"#include "apr_queue.h"#include "apr_atomic.h"#include "apr_want.h"#include "apr_version.h"#include <stdlib.h>#include "ap_config.h"#include "httpd.h"#include "http_main.h"#include "http_log.h"#include "http_config.h"#include "http_core.h"#include "http_connection.h"#include "http_protocol.h"#include "ap_mpm.h"#include "mpm_common.h"#include "ap_listen.h"#include "scoreboard.h"#include "mpm_fdqueue.h"#include "mpm_default.h"#include "http_vhost.h"#include "unixd.h"#include "apr_skiplist.h"#include <signal.h>#include <limits.h>Go to the source code of this file.
Classes | |
| struct | event_conn_state_t |
| struct | timeout_head_t |
| struct | timeout_queue |
| struct | proc_info |
| struct | thread_starter |
| struct | listener_poll_type |
| struct | event_retained_data |
| struct | event_child_bucket |
| struct | event_srv_cfg_s |
Macros | |
| #define | APR_WANT_STRFUNC |
| #define | DEFAULT_SERVER_LIMIT 16 |
| #define | MAX_SERVER_LIMIT 20000 |
| #define | DEFAULT_THREAD_LIMIT 64 |
| #define | MAX_THREAD_LIMIT 100000 |
| #define | MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) |
| #define | MAX_SECS_TO_LINGER 30 |
| #define | SECONDS_TO_LINGER 2 |
| #define | DEFAULT_WORKER_FACTOR 2 |
| #define | WORKER_FACTOR_SCALE 16 /* scale factor to allow fractional values */ |
| #define | TIMEOUT_FUDGE_FACTOR apr_time_from_msec(100) |
| #define | TO_QUEUE_ELEM_INIT(el) APR_RING_ELEM_INIT((el), timeout_list) |
| #define | MAX_SPAWN_RATE (32) |
| #define | ID_FROM_CHILD_THREAD(c, t) ((c * thread_limit) + t) |
| #define | LISTENER_SIGNAL SIGHUP |
| #define | close_socket_nonblocking(csd) close_socket_nonblocking_(csd, __FUNCTION__, __LINE__) |
| #define | ST_INIT 0 |
| #define | ST_GRACEFUL 1 |
| #define | ST_UNGRACEFUL 2 |
| #define | EVENT_FUDGE_FACTOR apr_time_from_msec(10) |
| #define | LINGERING_BUF_SIZE (32 * 1024) |
| #define | NON_WAKEABLE_POLL_TIMEOUT apr_time_from_msec(100) |
Enumerations | |
| enum | poll_type_e { PT_CSD , PT_ACCEPT } |
| #define APR_WANT_STRFUNC |
This MPM tries to fix the 'keep alive problem' in HTTP.
After a client completes the first request, the client can keep the connection open to send more requests with the same socket. This can save significant overhead in creating TCP connections. However, the major disadvantage is that Apache traditionally keeps an entire child process/thread waiting for data from the client. To solve this problem, this MPM has a dedicated thread for handling both the Listening sockets, and all sockets that are in a Keep Alive status.
The MPM assumes the underlying apr_pollset implementation is somewhat threadsafe. This currently is only compatible with KQueue and EPoll. This enables the MPM to avoid extra high level locking or having to wake up the listener thread when a keep-alive socket needs to be sent to it.
This MPM does not perform well on older platforms that do not have very good threading, like Linux with a 2.4 kernel, but this does not matter, since we require EPoll or KQueue.
For FreeBSD, use 5.3. It is possible to run this MPM on FreeBSD 5.2.1, if you use libkse (see man libmap.conf).
For NetBSD, use at least 2.0.
For Linux, you should use a 2.6 kernel, and make sure your glibc has epoll support compiled in.
| #define close_socket_nonblocking | ( | csd | ) | close_socket_nonblocking_(csd, __FUNCTION__, __LINE__) |
| #define EVENT_FUDGE_FACTOR apr_time_from_msec(10) |
| #define MPM_CHILD_PID | ( | i | ) | (ap_scoreboard_image->parent[i].pid) |
| #define NON_WAKEABLE_POLL_TIMEOUT apr_time_from_msec(100) |
| #define TIMEOUT_FUDGE_FACTOR apr_time_from_msec(100) |
| #define TO_QUEUE_ELEM_INIT | ( | el | ) | APR_RING_ELEM_INIT((el), timeout_list) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
< Adding or removing a descriptor is * thread-safe
< Descriptors passed to apr_pollset_add() * are not copied
< Do not detach
< Detach
< Module has handled this stage.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
< Module has handled this stage.
< Module has handled this stage.
< Module has served the response completely * - it's safe to die() with no more output
< Module has served the response completely * - it's safe to die() with no more output
< Module has served the response completely * - it's safe to die() with no more output
< Module has handled this stage.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
< Set on non-blocking sockets * (timeout != 0) on which the * previous read() did not fill a buffer * completely. the next apr_socket_recv() * will first call select()/poll() rather than * going straight into read(). (Can also * be set by an application to force a * select()/poll() call before the next * read, in cases where the app expects * that an immediate read would fail.)
|
static |
< Module has handled this stage.
< Module has handled this stage.
< Module has served the response completely * - it's safe to die() with no more output
XXX If the platform does not have a usable way of bundling accept() with a socket readability check, like Win32, and there are measurable delays before the socket is readable due to the first data packet arriving, it might be better to create the cs on the listener thread with the state set to CONN_STATE_CHECK_REQUEST_LINE_READABLE
FreeBSD users will want to enable the HTTP accept filter module in their kernel for the highest performance When the accept filter is active, sockets are kept in the kernel until a HTTP request is received.
< Module has handled this stage.
< Module has served the response completely * - it's safe to die() with no more output
< Module has handled this stage.
< Module has handled this stage.
|
static |
|
static |
|
static |
|
static |
|
static |
< Adding or removing a descriptor is * thread-safe
< Descriptors passed to apr_pollset_add() * are not copied
< Poll operations are interruptable by * apr_pollset_wakeup() or apr_pollcb_wakeup()
< Do not try to use the default method if * the specified non-default method cannot be * used
< Do not try to use the default method if * the specified non-default method cannot be * used
< Poll operations are interruptable by * apr_pollset_wakeup() or apr_pollcb_wakeup()
< Can read without blocking
< Hangup occurred
< Pending error
< Non-blocking IO
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |