Name
Child Exit
Synopsis
void child_exit(server_rec *pServer,pool *pPool) [1.3]
This function is called immediately before a particular child exits. See Child Initialization; earlier in this chapter, for an explanation of what “child”; means in this context. Typically, this function will be used to release resources that are persistent between connections, such as database or file handles.
In 2.0 there is no child_exit
hook — instead
one registers a cleanup function with the pool passed in the
init_child
hook.
See Example 21-24 for an excerpt from mod_log_config.c.
Example
static void flush_all_logs(server_rec *s, pool *p) { multi_log_state *mls; array_header *log_list; config_log_state *clsarray; int i; for (; s; s = s->next) { mls = ap_get_module_config(s->module_config, &config_log_module); log_list = NULL; if (mls->config_logs->nelts) { log_list = mls->config_logs; } else if (mls->server_config_logs) { log_list = mls->server_config_logs; } if (log_list) { clsarray = (config_log_state *) log_list->elts; for (i = 0; i < log_list->nelts; ++i) { flush_log(&clsarray[i]); } } } }
This routine is only used when BUFFERED_LOGS
is
defined. Predictably enough, it flushes all the buffered logs, which
would otherwise be lost when the child exited.
In 2.0, the same function is used, but it is registered via the
init_child
hook:
static void init_child(apr_pool_t *p, server_rec *s) { #ifdef BUFFERED_LOGS /* Now register the last buffer flush with the cleanup ...
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.