[MS4W-Users] How to implement the Nginx child_init hooks similar in Apache hooks
Govinda Rajulu
grajulu7 at gmail.com
Thu Feb 21 23:31:44 EST 2019
Hi Team,
I am started writing hook in nginx module similar like apache_hook. Can
you please help me in writing hook in nginx similar implementation in
apache as below
current implementation in Apache:
step 1: ap_hook_child_init(tap_child_init, NULL, NULL, APR_HOOK_MIDDLE);
step 2: function definition:
static void tap_child_init(apr_pool_t *p, server_rec *s) {
ta_config *conf = ap_get_module_config(s->module_config, &ta_apache_module);
child_setup(conf, p, s);
apr_pool_cleanup_register(p, s, tap_child_exit, tap_child_exit);
}
step 3:
static void child_setup(ta_config *conf, apr_pool_t *server_pool,
server_rec *s) {
apr_status_t rv = APR_SUCCESS;
curl_global_init(CURL_GLOBAL_ALL);
rv = apr_pool_create(&conf->pool, s->process->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
"Error while trying to initialize apr_pool for configuration");
return;
}
rv = create_config_updater_thread(conf->pool, s, conf);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
"Error while trying to initialize a thread for configuration polling");
return;
}
conf->curl_pool = curl_pool_create(server_pool, conf->curl_pool_size,
FALSE);
}
step 4:
static apr_status_t create_config_updater_thread(apr_pool_t *pool,
server_rec *s, ta_config *conf) {
apr_status_t rv;
thread_data_t *data = (thread_data_t *)apr_palloc(pool,
sizeof(thread_data_t));
data->server = s;
data->conf = conf;
rv = apr_thread_cond_create(&conf->config_updater_cond, pool);
if (rv != APR_SUCCESS) {
log_error("Error while init config_updater thread cond");
return rv;
}
rv = apr_thread_mutex_create(&conf->config_updater_cond_mutex, 0, pool);
if (rv != APR_SUCCESS) {
log_error("Error while creating config_updater thread mutex");
return rv;
}
rv = apr_thread_create(&conf->config_updater_thread, NULL,
config_updater, (void*)data, pool);
if (rv != APR_SUCCESS) {
log_error("Error while creating the config_updater thread");
return rv;
}
return rv;
}
Please help me in nginx hooks implementation part.
THanks,
Govinda P
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ms4w.com/pipermail/ms4w-users/attachments/20190222/c67e2758/attachment.html>
More information about the MS4W-Users
mailing list