Commit a73d025c authored by Justin Erenkrantz's avatar Justin Erenkrantz
Browse files

* server/mpm/experimental/event/event.c: Go through and reformat and correct

comments to be more appropriate.

*no functional changes*


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@109773 13f79535-47bb-0310-9956-ffa450edef68
parent 6a9b430c
Loading
Loading
Loading
Loading
+58 −53
Original line number Diff line number Diff line
@@ -16,24 +16,25 @@
/**
 * This MPM tries to fix the 'keep alive problem' in HTTP.
 *
 * After a client completes the first request, it can keep it open to send more 
 * requests with the same socket.  This can save signifigant 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.  This MPM has a dedicated thread for handling both the 
 * Listenting sockets, and all sockets that are in a Keep Alive status.
 * 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
 * signifigant 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 Listenting sockets,
 * and all sockets that are in a Keep Alive status.
 *
 * The MPM assumes the underlying apr_pollset implmentation is somewhat threadsafe.
 * This currently is only comptaible 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.
 * The MPM assumes the underlying apr_pollset implmentation 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 not preform 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 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.
 *
@@ -249,7 +250,8 @@ static apr_os_thread_t *listener_os_thread;
#define LISTENER_SIGNAL     SIGHUP

/* An array of socket descriptors in use by each thread used to
 * perform a non-graceful (forced) shutdown of the server. */
 * perform a non-graceful (forced) shutdown of the server.
 */
static apr_socket_t **worker_sockets;

static void close_worker_sockets(void)
@@ -637,12 +639,12 @@ static int process_socket(apr_pool_t * p, apr_socket_t * sock,
        listener_poll_type *pt = (listener_poll_type *) cs->pfd.client_data;

        /* It greatly simplifies the logic to use a single timeout value here
         * because the new element can just be added to the end of the list 
         * and it will stay sorted in expiration time sequence.  If brand new 
         * because the new element can just be added to the end of the list and
         * it will stay sorted in expiration time sequence.  If brand new
         * sockets are sent to the event thread for a readability check, this
         * will be a slight behavior change - they use the non-keepalive timeout 
         * today.  With a normal client, the socket will be readable in a few 
         * milliseconds anyway.    
         * will be a slight behavior change - they use the non-keepalive
         * timeout today.  With a normal client, the socket will be readable in
         * a few milliseconds anyway.
         */
        cs->expiration_time = ap_server_conf->keep_alive_timeout + time_now;
        apr_thread_mutex_lock(timeout_mutex);
@@ -753,7 +755,6 @@ static apr_status_t push2worker(const apr_pollfd_t * pfd,
 *     this prevents the worker queue from overflowing and lets
 *     other processes accept new connections in the mean time.
 */

static int get_worker(int *have_idle_worker_p)
{
    apr_status_t rc;
@@ -846,8 +847,8 @@ static void *listener_thread(apr_thread_t * thd, void *dummy)
                            tpool, APR_POLLSET_THREADSAFE);
    if (rc != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf,
                     "apr_pollset_create with Thread Safety failed.  Attempting to "
                     "shutdown process gracefully");
                     "apr_pollset_create with Thread Safety failed. "
                     "Attempting to shutdown process gracefully");
        signal_threads(ST_GRACEFUL);
        return NULL;
    }
@@ -961,8 +962,9 @@ static void *listener_thread(apr_thread_t * thd, void *dummy)

                rc = lr->accept_func(&csd, lr, ptrans);

                /* later we trash rv and rely on csd to indicate success/failure */

                /* later we trash rv and rely on csd to indicate
                 * success/failure
                 */
                AP_DEBUG_ASSERT(rc == APR_SUCCESS || !csd);

                if (rc == APR_EGENERAL) {
@@ -1088,8 +1090,8 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy)
        rv = ap_queue_pop(worker_queue, &csd, &cs, &ptrans);

        if (rv != APR_SUCCESS) {
            /* We get APR_EOF during a graceful shutdown once all the connections
             * accepted by this server process have been handled.
            /* We get APR_EOF during a graceful shutdown once all the
             * connections accepted by this server process have been handled.
             */
            if (APR_STATUS_IS_EOF(rv)) {
                break;
@@ -1464,10 +1466,12 @@ static void child_main(int child_num_arg)
         *     shutdown this child
         */
        join_start_thread(start_thread_id);
        signal_threads(ST_UNGRACEFUL);  /* helps us terminate a little more
                                         * quickly than the dispatch of the signal thread
                                         * beats the Pipe of Death and the browsers

        /* helps us terminate a little more quickly than the dispatch of the
         * signal thread; beats the Pipe of Death and the browsers
         */
        signal_threads(ST_UNGRACEFUL);

        /* A terminating signal was received. Now join each of the
         * workers to clean them up.
         *   If the worker already exited, then the join frees
@@ -2007,7 +2011,8 @@ static int worker_pre_config(apr_pool_t * pconf, apr_pool_t * plog,
    for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) {
        if (strncasecmp(pdir->directive, "ThreadsPerChild", 15) == 0) {
            if (!max_clients) {
                break;          /* we're in the clear, got ThreadsPerChild first */
                /* we're in the clear, got ThreadsPerChild first */
                break;
            }
            else {
                /* now to swap the data */
@@ -2231,8 +2236,8 @@ static const char *set_threads_per_child(cmd_parms * cmd, void *dummy,
                     "WARNING: ThreadsPerChild of %d exceeds ThreadLimit "
                     "value of %d", ap_threads_per_child, thread_limit);
        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                     "threads, lowering ThreadsPerChild to %d. To increase, please"
                     " see the", thread_limit);
                     "threads, lowering ThreadsPerChild to %d. To increase, "
                     "please see the", thread_limit);
        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                     " ThreadLimit directive.");
        ap_threads_per_child = thread_limit;