Erasing HTTPD library global variables before reinitialize server
am 01.12.2009 17:57:33 von Ishay LaviHello!
I build my application vs. libhttpd (Apache) library (for adding HTTP serv=
er 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 use=
d in the Apache httpd project =93main.c=94 file with one difference, I set =
back the 'apr_app_init_complete' (defined at 'start.c' file) global variabl=
e (again 'erasing global variables' issue) to zero (cause server to read ag=
ain 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 th=
at initialized and doesn=92t erased after 1st server running.
Specifically I saw it for the =91hooks=92 ( =93static struct { members } _h=
ooks;=94) global variable that defined at the =91apr_hooks.h=92 file, for t=
he 1st running it=92s fields set to =91NULL=92 value, but at 2nd it keep il=
legal 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 =3D (arr->nalloc <=3D 0) ? 1 : arr->nalloc *=
2;
char *new_data;
new_data =3D apr_palloc(arr->pool, arr->elt_size * new_si=
ze);
.
.
.
}
Call Stack for this exception:
> libapr-1.dll!apr_array_push(apr_array_header_t * arr=3D0x046299c0) =
Line 109 + 0x6 bytes C
libhttpd.dll!ap_hook_create_connection(conn_rec * (apr_pool_t *, se=
rver_rec *, apr_socket_t *, long, void *, apr_bucket_alloc_t *)* pf=3D0x6ff=
0c430, const char * const * aszPre=3D0x00000000, const char * const * aszSu=
cc=3D0x00000000, int nOrder=3D30) Line 42 + 0x41 bytes C
libhttpd.dll!register_hooks(apr_pool_t * p=3D0x043905b0) Line 3988=
C
libhttpd.dll!ap_register_hooks(module_struct * m=3D0x6ff47928, apr_=
pool_t * p=3D0x043905b0) Line 427 + 0xc bytes C
libhttpd.dll!ap_add_module(module_struct * m=3D0x6ff47928, apr_pool=
_t * p=3D0x043905b0) Line 554 C
libhttpd.dll!ap_setup_prelinked_modules(process_rec * process=3D0x0=
438f5c8) Line 697 + 0x12 bytes C
NOTE: The called to apr_array_push() procedure added using the 'APR_IMPLEME=
NT_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 nOrde=
r) \
{ \
ns##_LINK_##name##_t *pHook; \
if(!_hooks.link_##name) \
{ \
_hooks.link_##name=3Dapr_array_make(apr_hook_global_pool,1,s izeof(n=
s##_LINK_##name##_t)); \
apr_hook_sort_register(#name,&_hooks.link_##name); \
} \
pHook=3Dapr_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_PA=
RENT_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. The=
y 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, distributi=
on or copying of this communication is strictly prohibited and may be unlaw=
ful.
If you have received this email in error please immediately notify the send=
er and delete or destroy any copy of this message
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See
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