Commit 3e2a9f52 authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

Create new ap_state_query() function that allows modules to determine

if the current configuration run is the initial one at server startup,
and if the server is started for testing/config dumping only.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1070151 13f79535-47bb-0310-9956-ffa450edef68
parent a5fa0904
Loading
Loading
Loading
Loading
+5 −0
Changes for CHANGES: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,11 @@

Changes with Apache 2.3.11

  *) core: Create new ap_state_query function that allows modules to determine
     if the current configuration run is the initial one at server startup,
     and if the server is started for testing/config dumping only.
     [Stefan Fritsch]

  *) mod_cache: When a bad Expires date is present, we need to behave as if
     the Expires is in the past, not as if the Expires is missing. PR 16521.
     [Co-Advisor <coad@measurement-factory.com>]
+2 −1
Changes for include/ap_mmn.h: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -299,6 +299,7 @@
 *                         Add pool argument to ap_add_file_conf().
 * 20110117.1 (2.3.11-dev) Add ap_pstr2_alnum() and ap_str2_alnum()
 * 20110203.0 (2.3.11-dev) Raise DYNAMIC_MODULE_LIMIT to 256
 * 20110203.1 (2.3.11-dev) Add ap_state_query()
 */

#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -306,7 +307,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20110203
#endif
#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */

/**
 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+46 −0
Changes for include/http_core.h: 46 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -792,6 +792,52 @@ APR_DECLARE_OPTIONAL_FN(int, access_compat_ap_satisfies, (request_rec *r));

/* ---------------------------------------------------------------------- */

/** Query the server for some state information
 * @param query_code Which information is requested
 * @return the requested state information
 */
AP_DECLARE(int) ap_state_query(int query_code);

/*
 * possible values for query_code in ap_state_query()
 */

  /** current status of the server */
#define AP_SQ_MAIN_STATE        0
  /** are we going to serve requests or are we just testing/dumping config */
#define AP_SQ_RUN_MODE          1

/*
 * return values for ap_state_query()
 */

  /** return value for unknown query_code */
#define AP_SQ_NOT_SUPPORTED       -1

/* values returned for AP_SQ_MAIN_STATE */
  /** before the config preflight */
#define AP_SQ_MS_INITIAL_STARTUP   1
  /** initial configuration run for setting up log config, etc. */
#define AP_SQ_MS_CREATE_PRE_CONFIG 2
  /** tearing down configuration */
#define AP_SQ_MS_DESTROY_CONFIG    3
  /** normal configuration run */
#define AP_SQ_MS_CREATE_CONFIG     4
  /** running the MPM */
#define AP_SQ_MS_RUN_MPM           5
  /** cleaning up for exit */
#define AP_SQ_MS_EXITING           6

/* values returned for AP_SQ_RUN_MODE */
  /** command line not yet parsed */
#define AP_SQ_RM_UNKNOWN           1
  /** normal operation (server requests or signal server) */
#define AP_SQ_RM_NORMAL            2
  /** config test only */
#define AP_SQ_RM_CONFIG_TEST       3
  /** only dump some parts of the config */
#define AP_SQ_RM_CONFIG_DUMP       4

#ifdef __cplusplus
}
#endif
+4 −0
Changes for include/http_main.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@ AP_DECLARE_DATA extern const char *ap_server_root;
AP_DECLARE_DATA extern server_rec *ap_server_conf;
/** global pool, for access prior to creation of server_rec */
AP_DECLARE_DATA extern apr_pool_t *ap_pglobal;
/** state of the server (startup, exiting, ...) */
AP_DECLARE_DATA int ap_main_state;
/** run mode (normal, config test, config dump, ...) */
AP_DECLARE_DATA int ap_run_mode;

/* for -C, -c and -D switches */
/** An array of all -C directives.  These are processed before the server's
+15 −0
Changes for server/core.c: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -110,6 +110,9 @@ static char errordocument_default;
static apr_array_header_t *saved_server_config_defines = NULL;
static apr_table_t *server_config_defined_vars = NULL;

AP_DECLARE_DATA int ap_main_state = AP_SQ_MS_INITIAL_STARTUP;
AP_DECLARE_DATA int ap_run_mode = AP_SQ_RM_UNKNOWN;

static void *create_core_dir_config(apr_pool_t *a, char *dir)
{
    core_dir_config *conf;
@@ -4341,6 +4344,18 @@ static int core_pre_connection(conn_rec *c, void *csd)
    return DONE;
}

AP_DECLARE(int) ap_state_query(int query)
{
    switch (query) {
    case AP_SQ_MAIN_STATE:
        return ap_main_state;
    case AP_SQ_RUN_MODE:
        return ap_run_mode;
    default:
        return AP_SQ_NOT_SUPPORTED;
    }
}

static void register_hooks(apr_pool_t *p)
{
    errorlog_hash = apr_hash_make(p);
Loading