Commit 23d8ef44 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Bring mod_status for 2.0 back in line with mod_status for 1.3. This is

basically a straight port of the 1.3 module to 2.0.  The MPMs need to be
modified a bit to work with mod_status, but prefork, mpmt_pthread, and
dexter have already been changed.  I will fix perchild tonight.  There
is a lot of common code that can be abstracted, and there seems to be a
small bug with regard to what mpmt_pthread and dexter report as current
connections.  ExtendedStatus does work again, although until the bug
mentioned above is fixed, it isn't as useful on mpmt_pthread and dexter.

Next week, I will look at allowing other modules to add data to the
STATUS page and possibly to the scoreboard itself.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87949 13f79535-47bb-0310-9956-ffa450edef68
parent 851e8f55
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
Changes with Apache 2.0b1

  *) Make mod_status work with 2.0.  This will work for prefork,
     mpmt_pthread, and dexter.  [Ryan Bloom]

  *) Correct a typo in httpd.conf.
     [Kunihiro Tanaka <tanaka@apache.or.jp>] PR#7154 

include/mpm_status.h

deleted100644 → 0
+0 −137
Original line number Diff line number Diff line
/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

/*
 * TODO: Possible additions to this API include getting a list of connection
 * IDs and a list of keys in a particular row.
 */

#ifndef APACHE_MPM_STATUS_H
#define APACHE_MPM_STATUS_H

#include "apr_lib.h"

/**
 * @package MPM Status API
 */

typedef struct ap_status_table_row_t ap_status_table_row_t;
/** 
 * The MPM status table row structure.  MPMs should use this structure in
 * a table to store the status for the requests.  This structure stores the
 * status for one connection 
 */ 
struct ap_status_table_row_t {
    /** The connection id.  This is used as a key for the status table */
    long conn_id;
    /** The actual status.  This is a table of key-value pairs */
    apr_table_t *data;
};

/**
 * Get a cell from the status table. Don't mess with the string you get.
 * @param conn_id Connection ID of the current connection
 * @param key The key to determine which status value should be retrieved
 *            for the connection.
 * @deffunc const char *ap_get_connection_status(long conn_id, const char *key)
 */
AP_DECLARE(const char *) ap_get_connection_status(long conn_id, const char *key);

/**
 * Get an array of current connection IDs.
 * @param p The pool to allocate the array out of
 * @return An array of all the current connection IDs
 * @deffunc apr_array_header_t *ap_get_connections(apr_pool_t *p)
 */
AP_DECLARE(apr_array_header_t *) ap_get_connections(apr_pool_t *p);

/**
 * Get an array of keys from a given connection.
 * @param p Pool to allocate out of
 * @param conn_id Connection ID to get the keys for
 * @return an array of keys from a given connection
 * @deffunc apr_array_header_t *ap_get_connection_keys(apr_pool_t *p, long conn_id)
 */
AP_DECLARE(apr_array_header_t *) ap_get_connection_keys(apr_pool_t *p,
                                                       long conn_id);

/**
 * Set a cell in the status table. No guarantees are made that long strings
 * won't be truncated.
 * @param conn_id Connection ID to update
 * @param key key to update
 * @param value value to set for the key
 * @deffunc void ap_update_connection_status(long conn_id, const char *key, const char *value)
 */
AP_DECLARE(void) ap_update_connection_status(long conn_id, const char *key, const char *value);

/**
 * Clear out this connection's status values. Normally called when a
 * connection is closed
 * @param conn_id The connection ID to clear
 * @deffunc void ap_reset_connection_status(long conn_id)
 */
AP_DECLARE(void) ap_reset_connection_status(long conn_id);

/**
 * Returns the most up-to-date status table available, in the form of an array
 * of ap_status_row_t's.
 * @param p pool to allocate the array out of, generally from the request_rec
 * @return The table of statuses for all connections
 * @deffunc apr_array_header_t *ap_get_status_table(apr_pool_t *p)
 */
AP_DECLARE(apr_array_header_t *) ap_get_status_table(apr_pool_t *p);

#endif /* APACHE_SERVER_STATS_H */
+6 −6
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@

#ifndef APACHE_SCOREBOARD_H
#define APACHE_SCOREBOARD_H
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -139,13 +138,13 @@ typedef unsigned vtime_t;
 */
typedef int ap_generation_t;

/* stuff which is thread specific */
/* stuff which is thread/process specific */
typedef struct {
#ifdef OPTIMIZE_TIMEOUTS
    vtime_t cur_vtime;		/* the child's current vtime */
    unsigned short timeout_len;	/* length of the timeout */
#endif
    pthread_t tid;
    int thread_num;
    unsigned char status;
    unsigned long access_count;
    unsigned long bytes_served;
@@ -165,7 +164,7 @@ typedef struct {
    char request[64];		/* We just want an idea... */
    server_rec *vhostrec;	/* What virtual host is being accessed? */
                                /* SEE ABOVE FOR SAFE USAGE! */
} thread_score;
} short_score;

typedef struct {
    ap_generation_t running_generation;	/* the generation of children which
@@ -184,7 +183,7 @@ typedef struct {
} parent_score;

typedef struct {
    thread_score servers[HARD_SERVER_LIMIT][HARD_THREAD_LIMIT];
    short_score servers[HARD_SERVER_LIMIT][HARD_THREAD_LIMIT];
    parent_score parent[HARD_SERVER_LIMIT];
    global_score global;
} scoreboard;
@@ -214,7 +213,6 @@ AP_DECLARE(int) ap_exists_scoreboard_image(void);
void reinit_scoreboard(apr_pool_t *p);
apr_status_t ap_cleanup_shared_mem(void *d);
AP_DECLARE(void) ap_sync_scoreboard_image(void);
void ap_mpmt_pthread_force_reset_connection_status(long conn_id);

AP_DECLARE(void) reopen_scoreboard(apr_pool_t *p);

@@ -228,6 +226,8 @@ void ap_time_process_request(int child_num, int thread_num, int status);

AP_DECLARE_DATA extern scoreboard *ap_scoreboard_image;
AP_DECLARE_DATA extern const char *ap_scoreboard_fname;
AP_DECLARE_DATA extern int ap_extended_status;
AP_DECLARE_DATA apr_time_t ap_restart_time;

AP_DECLARE_DATA extern ap_generation_t volatile ap_my_generation;

+670 −36

File changed.

Preview size limit exceeded, changes collapsed.

+13 −3
Original line number Diff line number Diff line
@@ -91,7 +91,6 @@
#include "util_date.h"          /* For parseHTTPdate and BAD_DATE */
#include "util_charset.h"
#include "util_ebcdic.h"
#include "mpm_status.h"

#include "mod_core.h"

@@ -1211,7 +1210,9 @@ static int read_request_line(request_rec *r)
    char l[DEFAULT_LIMIT_REQUEST_LINE + 2]; /* getline's two extra for \n\0 */
    const char *ll = l;
    const char *uri;
#if 0
    conn_rec *conn = r->connection;
#endif
    int major = 1, minor = 0;   /* Assume HTTP/1.0 if non-"HTTP" protocol */
    int len;

@@ -1277,7 +1278,12 @@ static int read_request_line(request_rec *r)
    r->request_time = apr_now();
    r->the_request = apr_pstrdup(r->pool, l);
    r->method = ap_getword_white(r->pool, &ll);
    ap_update_connection_status(conn->id, "Method", r->method);
#if 0
/* XXX If we want to keep track of the Method, the protocol module should do
 * it.  That support isn't in the scoreboard yet.  Hopefully next week 
 * sometime.   rbb */
    ap_update_connection_status(AP_CHILD_THREAD_FROM_ID(conn->id), "Method", r->method); 
#endif
    uri = ap_getword_white(r->pool, &ll);

    /* Provide quick information about the request method as soon as known */
@@ -1302,7 +1308,11 @@ static int read_request_line(request_rec *r)

    r->assbackwards = (ll[0] == '\0');
    r->protocol = apr_pstrdup(r->pool, ll[0] ? ll : "HTTP/0.9");
/* XXX If we want to keep track of the Method, the protocol module should do
 * it.  That support isn't in the scoreboard yet.  Hopefully next week 
 * sometime.   rbb
    ap_update_connection_status(conn->id, "Protocol", r->protocol); 
 */

    if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor)
      && minor < HTTP_VERSION(1,0))	/* don't allow HTTP/0.1000 */
Loading