httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaelr <>
Subject child init/ exit and the apr_cleanup_register
Date Tue, 22 Nov 2011 08:19:45 GMT
Hello again,

maybe another stupid question but i could not found any
example in the modules dir of the httpd source.

Let's say i have an child_init_function which opens a 
filehandle. This filehandle should be open until the child

In mod_example.c they register an cleanup function to call a
function on child exit.

static apr_status_t child_exit ( void *data )
	//close file handle...

	return OK;

static void child_init ( apr_pool_t *p, server_rec *s )
	//open file handle...

	apr_pool_cleanup_register(p, s, NULL, child_exit) ;

I understand the cleanup as a function which runs on pool_cleanup.
This could happend on any time which i can't control - right?

When i return an HTTP_INTERNAL_SERVER_ERROR in my handler function
as an example the cleanup get's called also but the child is still
alive. The filehandle is closed and on the next request i run into
some kind of trouble.

Is there a way to define a 'real' exit function or can i force child
shutdown in above example? What's the right way to do it correctly?

Thanks a lot and greetings

View raw message