summaryrefslogtreecommitdiff
path: root/src/plugin.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-11-19 20:12:31 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2020-07-08 18:08:51 -0400
commitba88ff0e93ff686b95f696b5d05f56479b55f461 (patch)
tree863a3514e6e331418e1fe230c46bff05880daff3 /src/plugin.c
parentb73949e03f72349b2ce90276d275487044e26c67 (diff)
downloadlighttpd-git-ba88ff0e93ff686b95f696b5d05f56479b55f461.tar.gz
[core] run all trigger and sighup handlers
(do not bail if a handler returns something other than HANDLER_GO_ON) (preserve fn signature for simplicity and compat with plugin_fn_data)
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/plugin.c b/src/plugin.c
index ee458ff3..3923e20d 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -304,6 +304,15 @@ static handler_t plugins_call_fn_srv_data(server * const srv, const int e) {
return rc;
}
+static void plugins_call_fn_srv_data_all(server * const srv, const int e) {
+ const uint32_t offset = ((const uint16_t *)srv->plugin_slots)[e];
+ if (0 == offset) return;
+ const plugin_fn_data *plfd = (const plugin_fn_data *)
+ (((uintptr_t)srv->plugin_slots) + offset);
+ for (; plfd->fn; ++plfd)
+ plfd->fn(srv, plfd->data);
+}
+
/**
* plugins that use
*
@@ -340,17 +349,21 @@ PLUGIN_CALL_FN_SRV_CON_DATA(PLUGIN_FUNC_CONNECTION_RESET, connection_reset)
* - void *p_d (plugin_data *)
*/
-#define PLUGIN_CALL_FN_SRV_DATA(x, y) \
- handler_t plugins_call_##y(server *srv) {\
- return plugins_call_fn_srv_data(srv, x); \
- }
+handler_t plugins_call_set_defaults(server *srv) {
+ return plugins_call_fn_srv_data(srv, PLUGIN_FUNC_SET_DEFAULTS);
+}
-PLUGIN_CALL_FN_SRV_DATA(PLUGIN_FUNC_HANDLE_TRIGGER, handle_trigger)
-PLUGIN_CALL_FN_SRV_DATA(PLUGIN_FUNC_HANDLE_SIGHUP, handle_sighup)
-PLUGIN_CALL_FN_SRV_DATA(PLUGIN_FUNC_SET_DEFAULTS, set_defaults)
-PLUGIN_CALL_FN_SRV_DATA(PLUGIN_FUNC_WORKER_INIT, worker_init)
+handler_t plugins_call_worker_init(server *srv) {
+ return plugins_call_fn_srv_data(srv, PLUGIN_FUNC_WORKER_INIT);
+}
-#undef PLUGIN_CALL_FN_SRV_DATA
+void plugins_call_handle_trigger(server *srv) {
+ plugins_call_fn_srv_data_all(srv, PLUGIN_FUNC_HANDLE_TRIGGER);
+}
+
+void plugins_call_handle_sighup(server *srv) {
+ plugins_call_fn_srv_data_all(srv, PLUGIN_FUNC_HANDLE_SIGHUP);
+}
handler_t plugins_call_handle_waitpid(server *srv, pid_t pid, int status) {
const uint32_t offset =