Skip to content

Commit e70bea7

Browse files
author
Stefan Fritsch
committed
Pass ap_errorlog_info to error_log hook.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1204614 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3069896 commit e70bea7

6 files changed

Lines changed: 28 additions & 31 deletions

File tree

CHANGES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-*- coding: utf-8 -*-
22
Changes with Apache 2.5.0
33

4-
*) error log hook: add conn_rec as a parameter. [Jeff Trawick]
4+
*) error log hook: Pass ap_errorlog_info struct. [Stefan Fritsch]
55

66
[Apache 2.5.0-dev includes those bug fixes and changes with the
77
Apache 2.4.xx tree as documented below, except as noted.]

docs/manual/developer/new_api_2_4.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
<li>New function ap_get_server_name_for_url to support ipv6 literals.</li>
128128
<li>New function ap_register_errorlog_handler to register errorlog
129129
format string handlers.</li>
130+
<li>Arguments of error_log hook have changed. Declaration has moved to
131+
<code>http_core.h</code>.</li>
130132
<li>New function ap_state_query to determine if the server is in the
131133
initial configuration preflight phase or not. This is both easier to
132134
use and more correct than the old method of creating a pool userdata

include/ap_mmn.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,14 @@
368368
* 20111118.0 (2.5.0-dev) Add conn_rec to error_log hook
369369
* 20111118.1 (2.5.0-dev) Add reclvl to ap_expr_eval_ctx_t
370370
* 20111120.0 (2.5.0-dev) Remove parts of conn_state_t that are private to the MPM
371+
* 20111121.0 (2.5.0-dev) Pass ap_errorlog_info struct to error_log hook,
372+
* add pool to ap_errorlog_info.
371373
*/
372374

373375
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
374376

375377
#ifndef MODULE_MAGIC_NUMBER_MAJOR
376-
#define MODULE_MAGIC_NUMBER_MAJOR 20111120
378+
#define MODULE_MAGIC_NUMBER_MAJOR 20111121
377379
#endif
378380
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
379381

include/http_core.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,14 +776,17 @@ typedef struct ap_errorlog_info {
776776
/** r->main if r is a subrequest, otherwise equal to r */
777777
const request_rec *rmain;
778778

779-
/** name of source file where the log message was produced. */
779+
/** pool passed to ap_log_perror, NULL otherwise */
780+
apr_pool_t *pool;
781+
782+
/** name of source file where the log message was produced, NULL if N/A. */
780783
const char *file;
781784
/** line number in the source file, 0 if N/A */
782785
int line;
783786

784787
/** module index of module that produced the log message, APLOG_NO_MODULE if N/A. */
785788
int module_index;
786-
/** log level of error message, -1 if N/A */
789+
/** log level of error message (flags like APLOG_STARTUP have been removed), -1 if N/A */
787790
int level;
788791

789792
/** apr error status related to the log message, 0 if no error */
@@ -844,6 +847,19 @@ typedef struct {
844847
unsigned int min_loglevel;
845848
} ap_errorlog_format_item;
846849

850+
/**
851+
* hook method to log error messages
852+
* @ingroup hooks
853+
* @param info pointer to ap_errorlog_info struct which contains all
854+
* the details
855+
* @param errstr message to log (unmodified
856+
* @warning Allocating from the usual pools (pool, info->c->pool, info->p->pool)
857+
* must be avoided because it can cause memory leaks.
858+
* Use a subpool if necessary.
859+
*/
860+
AP_DECLARE_HOOK(void, error_log, (const ap_errorlog_info *info,
861+
const char *errstr))
862+
847863
AP_CORE_DECLARE(void) ap_register_log_hooks(apr_pool_t *p);
848864
AP_CORE_DECLARE(void) ap_register_config_hooks(apr_pool_t *p);
849865

include/http_log.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -624,26 +624,6 @@ AP_DECLARE(apr_file_t *) ap_piped_log_read_fd(piped_log *pl);
624624
*/
625625
AP_DECLARE(apr_file_t *) ap_piped_log_write_fd(piped_log *pl);
626626

627-
/**
628-
* hook method to log error messages
629-
* @ingroup hooks
630-
* @param file The file in which this function is called
631-
* @param line The line number on which this function is called
632-
* @param module_index The module_index of the module generating this message
633-
* @param level The level of this error message
634-
* @param status The status code from the previous command
635-
* @param s The server which we are logging for
636-
* @param c The connection which we are logging for
637-
* @param r The request which we are logging for
638-
* @param pool Memory pool to allocate from
639-
* @param errstr message to log
640-
*/
641-
AP_DECLARE_HOOK(void, error_log, (const char *file, int line,
642-
int module_index, int level,
643-
apr_status_t status, const server_rec *s,
644-
const conn_rec *c, const request_rec *r,
645-
apr_pool_t *pool, const char *errstr))
646-
647627
/**
648628
* hook method to generate unique id for connection or request
649629
* @ingroup hooks

server/log.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ static void log_error_core(const char *file, int line, int module_index,
11771177

11781178
info.s = s;
11791179
info.c = c;
1180+
info.pool = pool;
11801181
info.file = NULL;
11811182
info.line = 0;
11821183
info.status = 0;
@@ -1268,8 +1269,7 @@ static void log_error_core(const char *file, int line, int module_index,
12681269
* prefix and suffix.
12691270
*/
12701271
errstr[errstr_end] = '\0';
1271-
ap_run_error_log(file, line, module_index, level, status, s, c, r,
1272-
pool, errstr + errstr_start);
1272+
ap_run_error_log(&info, errstr + errstr_start);
12731273
}
12741274

12751275
*errstr = '\0';
@@ -1763,11 +1763,8 @@ AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val)
17631763
}
17641764

17651765
AP_IMPLEMENT_HOOK_VOID(error_log,
1766-
(const char *file, int line, int module_index, int level,
1767-
apr_status_t status, const server_rec *s,
1768-
const conn_rec *c, const request_rec *r,
1769-
apr_pool_t *pool, const char *errstr), (file, line,
1770-
module_index, level, status, s, c, r, pool, errstr))
1766+
(const ap_errorlog_info *info, const char *errstr),
1767+
(info, errstr))
17711768

17721769
AP_IMPLEMENT_HOOK_RUN_FIRST(int, generate_log_id,
17731770
(const conn_rec *c, const request_rec *r,

0 commit comments

Comments
 (0)