httpd-users mailing list archives

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

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) \
        { \
        _hooks.link_##name=apr_array_make(apr_hook_global_pool,1,sizeof(ns##_LINK_##name##_t));
\
        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?



P.S
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.



Thanks,

Ishay Lavi
Software Engineer
Web:   www.audiocodes.com
Email: ishay.lavi@audiocodes.com




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:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message