httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ishay Lavi <>
Subject [users@httpd] Erasing HTTPD library global variables before reinitialize server
Date Tue, 01 Dec 2009 16:57:33 GMT

I build my application vs. libhttpd (Apache) library  (for adding HTTP server abilities),
during application running it required to shutting down and then (after some time) to start
this (HTTP) server again.
The procedure I used to initialize/shutting down this server is same as used in the Apache
httpd project “main.c” file with one difference, I set back the 'apr_app_init_complete'
(defined at 'start.c' file) global variable (again 'erasing global variables' issue) to zero
(cause server to read again the CLI 'argc'/'argv' argument).

The problem occur in the 2nd  running, exception occur.
I debug it and I see that this issue caused by global (static) variables that initialized
and doesn’t erased after 1st server running.

Specifically I saw it for the ‘hooks’ ( “static struct { members } _hooks;”) global
variable that defined at the ‘apr_hooks.h’ file, for the 1st running it’s fields set
to ‘NULL’ value, but at 2nd it keep illegal addresses from the 1st running.

Location for this acceptation:
          APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr)
here==>       if (arr->nelts == arr->nalloc) {
                  int new_size = (arr->nalloc <= 0) ? 1 : arr->nalloc * 2;
                  char *new_data;

                  new_data = apr_palloc(arr->pool, arr->elt_size * new_size);

Call Stack for this exception:
>       libapr-1.dll!apr_array_push(apr_array_header_t * arr=0x046299c0)  Line 109 + 0x6
bytes  C
        libhttpd.dll!ap_hook_create_connection(conn_rec * (apr_pool_t *, server_rec *, apr_socket_t
*, long, void *, apr_bucket_alloc_t *)* pf=0x6ff0c430, const char * const * aszPre=0x00000000,
const char * const * aszSucc=0x00000000, int nOrder=30)  Line 42 + 0x41 bytes        C
        libhttpd.dll!register_hooks(apr_pool_t * p=0x043905b0)  Line 3988       C
        libhttpd.dll!ap_register_hooks(module_struct * m=0x6ff47928, apr_pool_t * p=0x043905b0)
 Line 427 + 0xc bytes   C
        libhttpd.dll!ap_add_module(module_struct * m=0x6ff47928, apr_pool_t * p=0x043905b0)
 Line 554   C
        libhttpd.dll!ap_setup_prelinked_modules(process_rec * process=0x0438f5c8)  Line 697
+ 0x12 bytes        C

NOTE: The called to apr_array_push() procedure added using the 'APR_IMPLEMENT_EXTERNAL_HOOK_BASE'
macro (defined at 'apr_hooks.h' file).
/** macro to implement the hook */
#define APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \
link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf,const char * const *aszPre,
                                      const char * const *aszSucc,int nOrder) \
    { \
    ns##_LINK_##name##_t *pHook; \
    if(!_hooks.link_##name) \
        { \
        apr_hook_sort_register(#name,&_hooks.link_##name); \
        } \
    pHook=apr_array_push(_hooks.link_##name); \

I use:
HTTPD version: httpd-2.2.13-win32-src
Platform: Windows, build with VC2005

Any suggestion?

I run it with the CLI -X (single process) option,
I use the 'SIGNAL_PARENT_SHUTDOWN' signal (e.g. "ap_signal_parent(SIGNAL_PARENT_SHUTDOWN)")
for terminate this (httpd) server.


Ishay Lavi
Software Engineer

This email and any files transmitted with it are confidential material. They are intended
solely for the use of the designated individual or entity to whom they are addressed. If the
reader of this message is not the intended recipient, you are hereby notified that any dissemination,
use, distribution or copying of this communication is strictly prohibited and may be unlawful.

If you have received this email in error please immediately notify the sender and delete or
destroy any copy of this message

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message