}
}
- trigger(NULL, NULL, "server.start", false, NULL);
+ trigger(NULL, NULL, NULL, "server.start", false, NULL);
/*
* Inform the parent (who should still be waiting) that the rest of
* Fire signal and stop triggers after ignoring SIGTERM, so handlers are
* not killed with the rest of the process group, below.
*/
- if (status == 2) trigger(NULL, NULL, "server.signal.term", true, NULL);
- trigger(NULL, NULL, "server.stop", false, NULL);
+ if (status == 2) trigger(NULL, NULL, NULL, "server.signal.term", true, NULL);
+ trigger(NULL, NULL, NULL, "server.stop", false, NULL);
/*
* Stop the scheduler, this signals the network and worker threads
#define CONN_TRIGGER(_state) do { \
if (conn->triggers) trigger(unlang_interpret_get_thread_default(), \
- conn->trigger_cs, fr_table_str_by_value(connection_trigger_names, _state, "<INVALID>"), true, conn->trigger_args); \
+ conn->trigger_cs, NULL, fr_table_str_by_value(connection_trigger_names, _state, "<INVALID>"), true, conn->trigger_args); \
} while (0)
#define STATE_TRANSITION(_new) \
talloc_array_length(entry->filename) - 1, false);
snprintf(name, sizeof(name), "%s.%s", ef->trigger_prefix, name_suffix);
- trigger(unlang_interpret_get_thread_default(), ef->conf, name, false, &args);
+ trigger(unlang_interpret_get_thread_default(), ef->conf, NULL, name, false, &args);
fr_pair_list_free(&args);
}
last_hup = when;
- trigger(unlang_interpret_get_thread_default(), NULL, "server.signal.hup", true, NULL);
+ trigger(unlang_interpret_get_thread_default(), NULL, NULL, "server.signal.hup", true, NULL);
fr_event_loop_exit(event_list, 0x80);
}
}
if (!pool->triggers_enabled) return;
snprintf(name, sizeof(name), "%s.%s", pool->trigger_prefix, event);
- trigger(unlang_interpret_get_thread_default(), pool->cs, name, true, &pool->trigger_args);
+ trigger(unlang_interpret_get_thread_default(), pool->cs, NULL, name, true, &pool->trigger_args);
}
/** Find a connection handle in the connection list
* If cs is not NULL, the portion after the last '.' in name is used for the trigger.
* If cs is NULL, the entire name is used to find the trigger in the global trigger
* section.
+ * @param[in,out] trigger_cp Optional pointer to a CONF_PAIR pointer. If populated and the pointer is not
+ * NULL, this CONF_PAIR will be used rather than searching.
+ * If populated, and the pointer is NULL, the search will happen and the pointer
+ * will be populated with the found CONF_PAIR.
* @param[in] name the path relative to the global trigger section ending in the trigger name
* e.g. module.ldap.pool.start.
* @param[in] rate_limit whether to rate limit triggers.
* - -2 if the trigger was rate limited.
* - -3 on failure.
*/
-int trigger(unlang_interpret_t *intp,
- CONF_SECTION const *cs, char const *name, bool rate_limit, fr_pair_list_t *args)
+int trigger(unlang_interpret_t *intp, CONF_SECTION const *cs, CONF_PAIR **trigger_cp,
+ char const *name, bool rate_limit, fr_pair_list_t *args)
{
CONF_ITEM *ci;
CONF_PAIR *cp;
*/
if (!trigger_cs || check_config) return 0;
+ /*
+ * Do we have a cached conf pair?
+ */
+ if (trigger_cp && *trigger_cp) {
+ cp = *trigger_cp;
+ goto cp_found;
+ }
+
/*
* A module can have a local "trigger" section. In which
* case that is used in preference to the global one.
cp = cf_item_to_pair(ci);
if (!cp) return -1;
+ if (trigger_cp) *trigger_cp = cp;
+
+cp_found:
value = cf_pair_value(cp);
if (!value) {
DEBUG3("Trigger has no value: %s", name);
int trigger_init(CONF_SECTION const *cs);
-int trigger(unlang_interpret_t *intp,
- CONF_SECTION const *cs, char const *name, bool rate_limit, fr_pair_list_t *args)
- CC_HINT(nonnull(3));
+int trigger(unlang_interpret_t *intp, CONF_SECTION const *cs, CONF_PAIR **trigger_cp,
+ char const *name, bool rate_limit, fr_pair_list_t *args) CC_HINT(nonnull(4));
bool trigger_enabled(void);
/** @} */
bool trigger_undef[NUM_ELEMENTS(trunk_conn_trigger_names)]; //!< Record that a specific trigger is undefined.
+
+ CONF_PAIR *trigger_cp[NUM_ELEMENTS(trunk_conn_trigger_names)]; //!< Cached trigger CONF_PAIRs
};
int trunk_trigger_cf_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
static size_t trunk_connection_events_len = NUM_ELEMENTS(trunk_connection_events);
#define CONN_TRIGGER(_state) do { \
- if (trunk->conf.conn_triggers && !trunk->trigger_undef[fr_high_bit_pos(_state)]) { \
- if (trigger(unlang_interpret_get_thread_default(), \
- trunk->conf.conn_trigger_cs, fr_table_str_by_value(trunk_conn_trigger_names, _state, \
- "<INVALID>"), true, NULL) == -1) { \
- trunk->trigger_undef[fr_high_bit_pos(_state)] = true; \
+ uint8_t idx = fr_high_bit_pos(_state); \
+ if (trunk->conf.conn_triggers && !trunk->trigger_undef[idx]) { \
+ if (trigger(unlang_interpret_get_thread_default(), trunk->conf.conn_trigger_cs, \
+ &trunk->trigger_cp[idx], \
+ fr_table_str_by_value(trunk_conn_trigger_names, _state, \
+ "<INVALID>"), true, NULL) == -1) { \
+ trunk->trigger_undef[idx] = true; \
} \
} \
} while (0)
#define REQUEST_TRIGGER(_state) do { \
if (trunk->conf.req_triggers) { \
trigger(unlang_interpret_get_thread_default(), \
- trunk->conf.req_trigger_cs, fr_table_str_by_value(trunk_req_trigger_names, _state, \
+ trunk->conf.req_trigger_cs, NULL, fr_table_str_by_value(trunk_req_trigger_names, _state, \
"<INVALID>"), true, NULL); \
} \
} while (0)
DEBUG3("Sync created with base dn \"%s\", filter \"%s\", msgid %i",
sync->config->base_dn, sync->config->filter, sync->msgid);
- trigger(unlang_interpret_get_thread_default(), config->cs, "modules.ldap_sync.start", true, &sync->trigger_args);
+ trigger(unlang_interpret_get_thread_default(), config->cs, NULL, "modules.ldap_sync.start", true, &sync->trigger_args);
return 0;
}
DEBUG3("Sync created with base dn \"%s\", filter \"%s\", msgid %i",
sync->config->base_dn, sync->config->filter, sync->msgid);
- trigger(unlang_interpret_get_thread_default(), config->cs, "modules.ldap_sync.start", true, &sync->trigger_args);
+ trigger(unlang_interpret_get_thread_default(), config->cs, NULL, "modules.ldap_sync.start", true, &sync->trigger_args);
/*
* Register event to store cookies at a regular interval
DEBUG3("Abandoning sync base dn \"%s\", filter \"%s\"", sync->config->base_dn, sync->config->filter);
- trigger(unlang_interpret_get_thread_default(), sync->config->cs, "modules.ldap_sync.stop", true, &sync->trigger_args);
+ trigger(unlang_interpret_get_thread_default(), sync->config->cs, NULL, "modules.ldap_sync.stop", true, &sync->trigger_args);
if (!sync->conn->handle) return 0; /* Handled already closed? */
DEBUG3("Sync created with base dn \"%s\", filter \"%s\", msgid %i",
sync->config->base_dn, sync->config->filter, sync->msgid);
- trigger(unlang_interpret_get_thread_default(), config->cs, "modules.ldap_sync.start", true, &sync->trigger_args);
+ trigger(unlang_interpret_get_thread_default(), config->cs, NULL, "modules.ldap_sync.start", true, &sync->trigger_args);
/*
* Register event to store cookies at a regular interval
fr_pair_list_init(&args);
MEM((vp = fr_pair_afrom_da_nested(crl, &args, attr_crl_cdp_url)));
fr_value_box_strdup_shallow(&vp->data, NULL, crl->cdp_url, true);
- trigger(unlang_interpret_get_thread_default(), crl->inst->cs, "modules.crl.expired",
+ trigger(unlang_interpret_get_thread_default(), crl->inst->cs, NULL, "modules.crl.expired",
crl->inst->trigger_rate_limit, &args);
}
return -1;
}
- trigger(unlang_interpret_get_thread_default(), inst->cs, "modules.crl.fetchuri", inst->trigger_rate_limit,
+ trigger(unlang_interpret_get_thread_default(), inst->cs, NULL, "modules.crl.fetchuri", inst->trigger_rate_limit,
&request->request_pairs);
if (unlang_module_yield_to_tmpl(rctx, &rctx->crl_data, request, vpt,
switch (fr_value_box_list_num_elements(&rctx->crl_data)) {
case 0:
REDEBUG("No CRL data returned from %pV, failing", rctx->cdp_url);
- trigger(unlang_interpret_get_thread_default(), inst->cs, "modules.crl.fetchfail",
+ trigger(unlang_interpret_get_thread_default(), inst->cs, NULL, "modules.crl.fetchfail",
inst->trigger_rate_limit, &request->request_pairs);
again:
talloc_free(rctx->cdp_url);
talloc_free(crl_data);
if (!crl_entry) {
RPERROR("Failed to process returned CRL data");
- trigger(unlang_interpret_get_thread_default(), inst->cs, "modules.crl.fetchbad",
+ trigger(unlang_interpret_get_thread_default(), inst->cs, NULL, "modules.crl.fetchbad",
inst->trigger_rate_limit, &request->request_pairs);
goto again;
}
fr_value_box_t *in_head = fr_value_box_list_head(in);
fr_value_box_t *vb;
- if (trigger(unlang_interpret_get(request), NULL, in_head->vb_strvalue, false, NULL) < 0) {
+ if (trigger(unlang_interpret_get(request), NULL, NULL, in_head->vb_strvalue, false, NULL) < 0) {
RPEDEBUG("Running trigger failed");
return XLAT_ACTION_FAIL;
}