[multiple] plugin.c handles common FREE_FUNC code

(simpler for modules; less boilerplate to cut-n-paste)
personal/stbuehler/ci-build
Glenn Strauss 2019-11-19 03:39:40 -05:00
parent ea75c0b87d
commit b73949e03f
51 changed files with 88 additions and 601 deletions

View File

@ -1156,11 +1156,9 @@ void gw_plugin_config_free(gw_plugin_config *s) {
free(s);
}
handler_t gw_free(server *srv, void *p_d) {
void gw_free(void *p_d) {
gw_plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
if (NULL == p->cvlist) { free(p); return HANDLER_GO_ON; }
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0];
@ -1175,9 +1173,6 @@ handler_t gw_free(server *srv, void *p_d) {
}
}
}
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_plugin_config *s, int sh_exec, const char *cpkkey) {

View File

@ -334,7 +334,7 @@ __attribute_cold__
void gw_plugin_config_free(gw_plugin_config *s);
__attribute_cold__
handler_t gw_free(server *srv, void *p_d);
void gw_free(void *p_d);
__attribute_cold__
int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_plugin_config *s, int sh_exec, const char *cpkkey);

View File

@ -25,17 +25,6 @@ INIT_FUNC(mod_access_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_access_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_access_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* url.access-deny */
@ -189,7 +178,6 @@ int mod_access_plugin_init(plugin *p) {
p->set_defaults = mod_access_set_defaults;
p->handle_uri_clean = mod_access_uri_handler;
p->handle_subrequest_start = mod_access_uri_handler;
p->cleanup = mod_access_free;
return 0;
}

View File

@ -451,7 +451,9 @@ static void mod_accesslog_free_format_fields(format_fields * const ff) {
free(ff);
}
static void mod_accesslog_free_config(plugin_data * const p) {
FREE_FUNC(mod_accesslog_free) {
plugin_data * const p = p_d;
free(p->syslog_logbuffer.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -476,20 +478,6 @@ static void mod_accesslog_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_accesslog_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_accesslog_free_config(p);
free(p->syslog_logbuffer.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_accesslog_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0:{/* accesslog.filename */

View File

@ -24,17 +24,6 @@ INIT_FUNC(mod_alias_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_alias_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_alias_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* alias.url */
@ -192,7 +181,6 @@ int mod_alias_plugin_init(plugin *p) {
p->init = mod_alias_init;
p->handle_physical= mod_alias_physical_handler;
p->set_defaults = mod_alias_set_defaults;
p->cleanup = mod_alias_free;
return 0;
}

View File

@ -50,7 +50,8 @@ INIT_FUNC(mod_auth_init) {
return p;
}
static void mod_auth_free_config(plugin_data * const p) {
FREE_FUNC(mod_auth_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -68,18 +69,6 @@ static void mod_auth_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_auth_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_auth_free_config(p);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
/* data type for mod_auth structured data
* (parsed from auth.require array of strings) */
typedef struct {

View File

@ -89,16 +89,6 @@ INIT_FUNC(mod_authn_file_init) {
return p;
}
FREE_FUNC(mod_authn_file_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_file_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.plain.groupfile */
@ -743,7 +733,6 @@ int mod_authn_file_plugin_init(plugin *p) {
p->name = "authn_file";
p->init = mod_authn_file_init;
p->set_defaults= mod_authn_file_set_defaults;
p->cleanup = mod_authn_file_free;
return 0;
}

View File

@ -68,16 +68,6 @@ INIT_FUNC(mod_authn_gssapi_init) {
return p;
}
FREE_FUNC(mod_authn_gssapi_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_gssapi_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.gssapi.keytab */
@ -791,7 +781,6 @@ int mod_authn_gssapi_plugin_init(plugin *p) {
p->name = "authn_gssapi";
p->init = mod_authn_gssapi_init;
p->set_defaults= mod_authn_gssapi_set_defaults;
p->cleanup = mod_authn_gssapi_free;
p->connection_reset = mod_authn_gssapi_handle_reset;
return 0;

View File

@ -56,7 +56,8 @@ INIT_FUNC(mod_authn_ldap_init) {
return p;
}
static void mod_authn_ldap_free_config(plugin_data *p) {
FREE_FUNC(mod_authn_ldap_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -75,19 +76,8 @@ static void mod_authn_ldap_free_config(plugin_data *p) {
}
}
}
}
FREE_FUNC(mod_authn_ldap_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_authn_ldap_free_config(p);
free(p->ldap_filter.ptr);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_ldap_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

View File

@ -64,7 +64,8 @@ typedef struct {
int mysql_conn_port;
} plugin_data;
static void mod_authn_mysql_sock_close(plugin_data *p) {
static void mod_authn_mysql_sock_close(void *p_d) {
plugin_data * const p = p_d;
if (NULL != p->mysql_conn) {
mysql_close(p->mysql_conn);
p->mysql_conn = NULL;
@ -155,18 +156,6 @@ INIT_FUNC(mod_authn_mysql_init) {
return p;
}
FREE_FUNC(mod_authn_mysql_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_authn_mysql_sock_close(p);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_mysql_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.mysql.host */
@ -522,7 +511,7 @@ int mod_authn_mysql_plugin_init(plugin *p) {
p->name = "authn_mysql";
p->init = mod_authn_mysql_init;
p->set_defaults= mod_authn_mysql_set_defaults;
p->cleanup = mod_authn_mysql_free;
p->cleanup = mod_authn_mysql_sock_close;
return 0;
}

View File

@ -45,16 +45,6 @@ INIT_FUNC(mod_authn_pam_init) {
return p;
}
FREE_FUNC(mod_authn_pam_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_pam_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.pam.opts */
@ -177,7 +167,6 @@ int mod_authn_pam_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = "authn_pam";
p->init = mod_authn_pam_init;
p->cleanup = mod_authn_pam_free;
p->set_defaults= mod_authn_pam_set_defaults;
return 0;

View File

@ -51,7 +51,9 @@ INIT_FUNC(mod_authn_sasl_init) {
return p;
}
static void mod_authn_sasl_free_config(plugin_data * const p) {
FREE_FUNC(mod_authn_sasl_free) {
plugin_data * const p = p_d;
if (p->initonce) sasl_done();
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -68,20 +70,6 @@ static void mod_authn_sasl_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_authn_sasl_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
if (p->initonce) sasl_done();
mod_authn_sasl_free_config(p);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_sasl_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.sasl.opts */

View File

@ -135,12 +135,7 @@ INIT_FUNC(mod_cgi_init) {
FREE_FUNC(mod_cgi_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
buffer_pid_t *r = &(p->cgi_pid);
UNUSED(srv);
if (r->ptr) free(r->ptr);
free(p->env.ptr);
free(p->env.offsets);
@ -150,11 +145,6 @@ FREE_FUNC(mod_cgi_free) {
#ifdef __CYGWIN__
buffer_free(p->env.systemroot);
#endif
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_cgi_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

View File

@ -18,7 +18,11 @@ INIT_FUNC(mod_cml_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_cml_free_config(plugin_data * const p) {
FREE_FUNC(mod_cml_free) {
plugin_data * const p = p_d;
free(p->trigger_handler.ptr);
free(p->basedir.ptr);
free(p->baseurl.ptr);
if (NULL == p->cvlist) return;
#if defined(USE_MEMCACHED)
/* (init i to 0 if global context; to 1 to skip empty global context) */
@ -77,23 +81,6 @@ static int mod_cml_init_memcached(server *srv, config_plugin_value_t * const cpv
#endif
}
FREE_FUNC(mod_cml_free) {
plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->trigger_handler.ptr);
free(p->basedir.ptr);
free(p->baseurl.ptr);
mod_cml_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_cml_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* cml.extension */

View File

@ -91,16 +91,8 @@ INIT_FUNC(mod_compress_init) {
FREE_FUNC(mod_compress_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
buffer_free(p->ofn);
buffer_free(p->b);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
/* 0 on success, -1 for error */

View File

@ -233,15 +233,7 @@ INIT_FUNC(mod_deflate_init) {
FREE_FUNC(mod_deflate_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->tmp_buf.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_deflate_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

View File

@ -116,7 +116,9 @@ INIT_FUNC(mod_dirlisting_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_dirlisting_free_config(plugin_data * const p) {
FREE_FUNC(mod_dirlisting_free) {
plugin_data * const p = p_d;
free(p->tmp_buf.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -138,21 +140,6 @@ static void mod_dirlisting_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_dirlisting_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_dirlisting_free_config(p);
free(p->tmp_buf.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_dirlisting_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* dir-listing.activate */

View File

@ -42,17 +42,6 @@ INIT_FUNC(mod_evasive_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_evasive_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_evasive_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* evasive.max-conns-per-ip */
@ -163,7 +152,6 @@ int mod_evasive_plugin_init(plugin *p) {
p->init = mod_evasive_init;
p->set_defaults = mod_evasive_set_defaults;
p->handle_uri_clean = mod_evasive_uri_handler;
p->cleanup = mod_evasive_free;
return 0;
}

View File

@ -50,7 +50,10 @@ static void mod_evhost_free_path_pieces(const buffer *path_pieces) {
free(b);
}
static void mod_evhost_free_config(plugin_data * const p) {
FREE_FUNC(mod_evhost_free) {
plugin_data * const p = p_d;
free(p->tmp_buf.ptr);
array_free_data(&p->split_vals);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -68,22 +71,6 @@ static void mod_evhost_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_evhost_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_evhost_free_config(p);
free(p->tmp_buf.ptr);
array_free_data(&p->split_vals);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
__attribute_cold__
static buffer * mod_evhost_parse_pattern_err(buffer *bptr) {
for (; bptr->ptr; ++bptr) free(bptr->ptr);

View File

@ -32,17 +32,6 @@ INIT_FUNC(mod_expire_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_expire_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_expire_get_offset(server *srv, plugin_data *p, const buffer *expire, time_t *offset) {
char *ts;
int type = -1;
@ -381,7 +370,6 @@ int mod_expire_plugin_init(plugin *p) {
p->init = mod_expire_init;
p->handle_response_start = mod_expire_handler;
p->set_defaults = mod_expire_set_defaults;
p->cleanup = mod_expire_free;
return 0;
}

View File

@ -142,7 +142,9 @@ INIT_FUNC(mod_extforward_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_extforward_free_config(plugin_data * const p) {
FREE_FUNC(mod_extforward_free) {
plugin_data * const p = p_d;
array_free(p->default_headers);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -159,20 +161,6 @@ static void mod_extforward_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_extforward_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_extforward_free_config(p);
array_free(p->default_headers);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_extforward_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* extforward.forwarder */

View File

@ -26,17 +26,6 @@ INIT_FUNC(mod_flv_streaming_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_flv_streaming_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_flv_streaming_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* flv-streaming.extensions */
@ -171,7 +160,6 @@ int mod_flv_streaming_plugin_init(plugin *p) {
p->init = mod_flv_streaming_init;
p->handle_physical = mod_flv_streaming_path_handler;
p->set_defaults = mod_flv_streaming_set_defaults;
p->cleanup = mod_flv_streaming_free;
return 0;
}

View File

@ -69,7 +69,8 @@ INIT_FUNC(mod_geoip_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_geoip_free_config(plugin_data * const p) {
FREE_FUNC(mod_geoip_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -87,19 +88,6 @@ static void mod_geoip_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_geoip_free) {
plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_geoip_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_geoip_open_db(server *srv, config_plugin_value_t * const cpv, int mem_cache) {
/* country db filename is required! */
if (buffer_is_empty(cpv->v.b)) {

View File

@ -30,17 +30,6 @@ INIT_FUNC(mod_indexfile_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_indexfile_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_indexfile_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* index-file.names */
@ -192,7 +181,6 @@ int mod_indexfile_plugin_init(plugin *p) {
p->init = mod_indexfile_init;
p->handle_subrequest_start = mod_indexfile_subrequest;
p->set_defaults = mod_indexfile_set_defaults;
p->cleanup = mod_indexfile_free;
return 0;
}

View File

@ -49,15 +49,7 @@ INIT_FUNC(mod_magnet_init) {
FREE_FUNC(mod_magnet_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
script_cache_free_data(&p->cache);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_magnet_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

View File

@ -107,8 +107,9 @@ INIT_FUNC(mod_maxminddb_init)
}
static void mod_maxminddb_free_config (plugin_data * const p)
FREE_FUNC(mod_maxminddb_free)
{
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -142,21 +143,6 @@ static void mod_maxminddb_free_config (plugin_data * const p)
}
FREE_FUNC(mod_maxminddb_free)
{
plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_maxminddb_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static MMDB_s *
mod_maxminddb_open_db (server *srv, const buffer *db_name)
{

View File

@ -27,7 +27,6 @@ typedef struct {
const buffer *mysql_query;
} plugin_config;
/* global plugin data */
typedef struct {
PLUGIN_DATA;
plugin_config defaults;
@ -36,19 +35,19 @@ typedef struct {
buffer tmp_buf;
} plugin_data;
/* per connection plugin data */
typedef struct {
buffer *server_name;
buffer *document_root;
} plugin_connection_data;
/* init the plugin data */
INIT_FUNC(mod_mysql_vhost_init) {
return calloc(1, sizeof(plugin_data));
}
/* cleanup the mysql connections */
static void mod_mysql_vhost_free_config(plugin_data * const p) {
FREE_FUNC(mod_mysql_vhost_cleanup) {
plugin_data * const p = p_d;
free(p->tmp_buf.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -66,22 +65,6 @@ static void mod_mysql_vhost_free_config(plugin_data * const p) {
}
}
/* cleanup the plugin data */
FREE_FUNC(mod_mysql_vhost_cleanup) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_mysql_vhost_free_config(p);
free(p->tmp_buf.ptr);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
/* handle the plugin per connection data */
static void* mod_mysql_vhost_connection_data(server *srv, connection *con, void *p_d)
{
plugin_data *p = p_d;
@ -98,7 +81,6 @@ static void* mod_mysql_vhost_connection_data(server *srv, connection *con, void
return con->plugin_ctx[p->id] = c;
}
/* destroy the plugin per connection data */
CONNECTION_FUNC(mod_mysql_vhost_handle_connection_reset) {
plugin_data *p = p_d;
plugin_connection_data *c = con->plugin_ctx[p->id];
@ -192,7 +174,6 @@ static MYSQL * mod_mysql_vhost_db_setup (server *srv, const char *dbname, const
return my;
}
/* set configuration values */
SETDEFAULTS_FUNC(mod_mysql_vhost_set_defaults) {
static const config_plugin_keys_t cpk[] = {
{ CONST_STR_LEN("mysql-vhost.sql"),
@ -285,7 +266,6 @@ SETDEFAULTS_FUNC(mod_mysql_vhost_set_defaults) {
return HANDLER_GO_ON;
}
/* handle document root request */
CONNECTION_FUNC(mod_mysql_vhost_handle_docroot) {
plugin_data *p = p_d;
plugin_connection_data *c;
@ -385,7 +365,7 @@ ERR500:
return HANDLER_FINISHED;
}
/* this function is called at dlopen() time and inits the callbacks */
int mod_mysql_vhost_plugin_init(plugin *p);
int mod_mysql_vhost_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;

View File

@ -104,6 +104,7 @@ typedef struct {
PLUGIN_DATA;
plugin_ssl_ctx *ssl_ctxs;
plugin_config defaults;
server *srv;
array *cafiles;
} plugin_data;
@ -284,16 +285,9 @@ mod_openssl_load_ca_files (SSL_CTX *ssl_ctx, plugin_data *p, server *srv)
FREE_FUNC(mod_openssl_free)
{
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_openssl_free_config(srv, p);
if (NULL == p->srv) return;
mod_openssl_free_config(p->srv, p);
mod_openssl_free_openssl();
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
@ -1581,6 +1575,7 @@ SETDEFAULTS_FUNC(mod_openssl_set_defaults)
};
plugin_data * const p = p_d;
p->srv = srv;
p->cafiles = array_init();
if (!config_plugin_values_init(srv, p, cpk, "mod_openssl"))
return HANDLER_ERROR;

View File

@ -92,12 +92,9 @@ static void mod_proxy_free_config(plugin_data * const p)
FREE_FUNC(mod_proxy_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
plugin_data * const p = p_d;
mod_proxy_free_config(p);
return gw_free(srv, p);
gw_free(p);
}
static void mod_proxy_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv)

View File

@ -27,7 +27,8 @@ INIT_FUNC(mod_redirect_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_redirect_free_config(plugin_data * const p) {
FREE_FUNC(mod_redirect_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -45,19 +46,6 @@ static void mod_redirect_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_redirect_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_redirect_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_redirect_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* url.redirect */

View File

@ -29,7 +29,8 @@ INIT_FUNC(mod_rewrite_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_rewrite_free_config(plugin_data * const p) {
FREE_FUNC(mod_rewrite_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -58,19 +59,6 @@ static void mod_rewrite_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_rewrite_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_rewrite_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_rewrite_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* url.rewrite-once */

View File

@ -39,6 +39,7 @@ typedef struct {
int rrdtool_running;
const buffer *path_rrdtool_bin;
server *srv;
} plugin_data;
INIT_FUNC(mod_rrd_init) {
@ -64,22 +65,15 @@ static void mod_rrd_free_config(plugin_data * const p) {
FREE_FUNC(mod_rrd_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
if (NULL == p->srv) return;
mod_rrd_free_config(p);
if (p->read_fd >= 0) close(p->read_fd);
if (p->write_fd >= 0) close(p->write_fd);
if (p->rrdtool_pid > 0 && p->srv_pid == srv->pid) {
if (p->rrdtool_pid > 0 && p->srv_pid == p->srv->pid) {
/* collect status (blocking) */
while (-1 == waitpid(p->rrdtool_pid, NULL, 0) && errno == EINTR) ;
}
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_rrd_create_pipe(server *srv, plugin_data *p) {
@ -179,6 +173,7 @@ SETDEFAULTS_FUNC(mod_rrd_set_defaults) {
};
plugin_data * const p = p_d;
p->srv = srv;
if (!config_plugin_values_init(srv, p, cpk, "mod_rrdtool"))
return HANDLER_ERROR;

View File

@ -229,17 +229,6 @@ INIT_FUNC(mod_secdownload_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_secdownload_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_secdownload_parse_algorithm(server * const srv, config_plugin_value_t * const cpv) {
secdl_algorithm algorithm = algorithm_from_string(cpv->v.b);
switch (algorithm) {
@ -549,7 +538,6 @@ int mod_secdownload_plugin_init(plugin *p) {
p->init = mod_secdownload_init;
p->handle_physical = mod_secdownload_uri_handler;
p->set_defaults = mod_secdownload_set_defaults;
p->cleanup = mod_secdownload_free;
return 0;
}

View File

@ -45,17 +45,6 @@ INIT_FUNC(mod_setenv_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_setenv_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_setenv_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* setenv.add-request-header */
@ -285,7 +274,6 @@ int mod_setenv_plugin_init(plugin *p) {
p->handle_request_env = mod_setenv_handle_request_env;
p->handle_response_start = mod_setenv_handle_response_start;
p->set_defaults = mod_setenv_set_defaults;
p->cleanup = mod_setenv_free;
p->connection_reset = mod_setenv_reset;

View File

@ -33,16 +33,8 @@ INIT_FUNC(mod_simple_vhost_init) {
FREE_FUNC(mod_simple_vhost_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->tmp_buf.ptr);
free(p->last_root.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_simple_vhost_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

View File

@ -59,18 +59,6 @@ INIT_FUNC(mod_skeleton_init) {
return calloc(1, sizeof(plugin_data));
}
/* destroy the plugin data */
FREE_FUNC(mod_skeleton_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
/* handle plugin config and check values */
static void mod_skeleton_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
@ -170,7 +158,6 @@ int mod_skeleton_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = "skeleton";
p->init = mod_skeleton_init;
p->cleanup = mod_skeleton_free;
p->set_defaults= mod_skeleton_set_defaults;
p->handle_uri_clean = mod_skeleton_uri_handler;

View File

@ -72,19 +72,10 @@ INIT_FUNC(mod_ssi_init) {
FREE_FUNC(mod_ssi_free) {
plugin_data *p = p_d;
UNUSED(srv);
if (!p) return HANDLER_GO_ON;
array_free(p->ssi_vars);
array_free(p->ssi_cgi_env);
buffer_free(p->timefmt);
buffer_free(p->stat_fn);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_ssi_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

View File

@ -33,17 +33,6 @@ INIT_FUNC(mod_staticfile_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_staticfile_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_staticfile_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* static-file.exclude-extensions */
@ -183,7 +172,6 @@ int mod_staticfile_plugin_init(plugin *p) {
p->init = mod_staticfile_init;
p->handle_subrequest_start = mod_staticfile_subrequest;
p->set_defaults = mod_staticfile_set_defaults;
p->cleanup = mod_staticfile_free;
return 0;
}

View File

@ -50,17 +50,6 @@ INIT_FUNC(mod_status_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_status_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_status_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* status.status-url */
@ -899,7 +888,6 @@ int mod_status_plugin_init(plugin *p) {
p->name = "status";
p->init = mod_status_init;
p->cleanup = mod_status_free;
p->set_defaults= mod_status_set_defaults;
p->handle_uri_clean = mod_status_handler;

View File

@ -59,7 +59,8 @@ INIT_FUNC(mod_trigger_b4_dl_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_trigger_b4_dl_free_config(plugin_data * const p) {
FREE_FUNC(mod_trigger_b4_dl_free) {
plugin_data *p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -183,19 +184,6 @@ static int mod_trigger_b4_dl_init_regex(server * const srv, config_plugin_value_
}
}
FREE_FUNC(mod_trigger_b4_dl_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_trigger_b4_dl_free_config(p);
free(p->cvlist);
free(p);