You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Dietz, Phil E." <PE...@west.com> on 2003/01/08 17:21:08 UTC

ap_hook_error_log hook segfault

Can someone explain why the below seg-faults ?

I'm writing a module using the error log hook, and for initial testing, am using ap_log_error.
I'd assume this should double log everything.


#include "apr_want.h"

#include "ap_config.h"     
#include "mod_log_config.h"
#include "httpd.h"
#include "http_config.h"        
#include "http_core.h"          /* For REMOTE_NAME */
#include "http_log.h"
#include "apr_optional.h"
#include "http_protocol.h"
#include "util_time.h"

module AP_MODULE_DECLARE_DATA myrerror_module;

/*************************************************************
 * replacement for ap_log_rerror                             *
 *************************************************************/
void
myrerror(const char *file, int line, int level, apr_status_t status, const server_rec *s, const request_rec *r, apr_pool_t *pool, const char *fmt)
{
        /* It core dumps on ap_log_error()...putting a return; here stops it from dumping. */
        if (s) ap_log_error(file, line, level, status, s, fmt);
        return;
}       /* myrerror */

static void register_hooks(apr_pool_t *p)
{
    ap_hook_error_log(myrerror,NULL,NULL,APR_HOOK_MIDDLE);
};

/**************************************************************
 * Module Defininition                                        *
 **************************************************************/
module AP_MODULE_DECLARE_DATA myrerror_module = {
    STANDARD20_MODULE_STUFF,
    NULL,           /* dir config creater */
    NULL,           /* dir merger --- default is to override */
    NULL,           /* server config */
    NULL,           /* merge server configs */
    NULL,           /* command apr_table_t */
    register_hooks  /* register hooks */
};