Browse Source

[core] new worker_init hook to follow parent fork

personal/stbuehler/ci-build
Glenn Strauss 3 years ago
parent
commit
f1e9bcb08a
  1. 3
      src/plugin.c
  2. 4
      src/plugin.h
  3. 4
      src/server.c

3
src/plugin.c

@ -50,6 +50,7 @@ typedef enum {
PLUGIN_FUNC_INIT,
PLUGIN_FUNC_CLEANUP,
PLUGIN_FUNC_SET_DEFAULTS,
PLUGIN_FUNC_WORKER_INIT,
PLUGIN_FUNC_SIZEOF
} plugin_t;
@ -348,6 +349,7 @@ PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_TRIGGER, handle_trigger)
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_SIGHUP, handle_sighup)
PLUGIN_TO_SLOT(PLUGIN_FUNC_CLEANUP, cleanup)
PLUGIN_TO_SLOT(PLUGIN_FUNC_SET_DEFAULTS, set_defaults)
PLUGIN_TO_SLOT(PLUGIN_FUNC_WORKER_INIT, worker_init)
#undef PLUGIN_TO_SLOT
@ -456,6 +458,7 @@ handler_t plugins_call_init(server *srv) {
PLUGIN_TO_SLOT(PLUGIN_FUNC_CONNECTION_RESET, connection_reset);
PLUGIN_TO_SLOT(PLUGIN_FUNC_CLEANUP, cleanup);
PLUGIN_TO_SLOT(PLUGIN_FUNC_SET_DEFAULTS, set_defaults);
PLUGIN_TO_SLOT(PLUGIN_FUNC_WORKER_INIT, worker_init);
#undef PLUGIN_TO_SLOT
if (p->init) {

4
src/plugin.h

@ -37,6 +37,7 @@ typedef struct {
void *(* init) ();
handler_t (* priv_defaults) (server *srv, void *p_d);
handler_t (* set_defaults) (server *srv, void *p_d);
handler_t (* worker_init) (server *srv, void *p_d); /* at server startup (each worker after fork()) */
handler_t (* cleanup) (server *srv, void *p_d);
/* is called ... */
handler_t (* handle_trigger) (server *srv, void *p_d); /* once a second */
@ -101,6 +102,9 @@ handler_t plugins_call_init(server *srv);
__attribute_cold__
handler_t plugins_call_set_defaults(server *srv);
__attribute_cold__
handler_t plugins_call_worker_init(server *srv);
__attribute_cold__
handler_t plugins_call_cleanup(server *srv);

4
src/server.c

@ -1787,6 +1787,10 @@ static int server_main (server * const srv, int argc, char **argv) {
return -1;
}
/* plugin hook for worker_init */
if (HANDLER_GO_ON != plugins_call_worker_init(srv))
return -1;
if (oneshot_fd && server_oneshot_init(srv, oneshot_fd)) {
oneshot_fd = -1;
}

Loading…
Cancel
Save