A recursive loop was the problem.

ap_log_error() calls log_error_core()...which triggers all ap_hook_error_log() hooks 
again.

I replaced myerror, with a complete copy of log_error_code() -- minus the call to 
ap_run_error_log() -- and it works fine.

Perhaps we should put a blurb in the docs or the source that ap_hook_error_log() 
functions can't call any functions with ap_log_* in them.

> -----Original Message-----
> From: Dietz, Phil E. 
> Sent: Wednesday, January 08, 2003 10:21 AM
> To:   [EMAIL PROTECTED]
> Subject:      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 */
> };
> 

Reply via email to