summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-03-25 08:56:08 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-03-25 08:56:08 +0000
commit62126e83e2b12a44d0220c2a1f4f10b5883e3977 (patch)
treede24ccbee0eeaf9e917aeec8f8aaf635da3aad02
parenta0e64f2e5fca4da0df650c02e83487ec27882f89 (diff)
When a plugin instance is used in multiple stack it is not necessary to
call the start function for each stack. Signed-off-by: Eric Leblond <eric@inl.fr>
-rw-r--r--src/ulogd.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/ulogd.c b/src/ulogd.c
index da821ee..7a779e6 100644
--- a/src/ulogd.c
+++ b/src/ulogd.c
@@ -710,6 +710,24 @@ create_stack_resolve_keys(struct ulogd_pluginstance_stack *stack)
return 0;
}
+/* iterate on already defined stack to find a plugininstance matching */
+static int pluginstance_started(struct ulogd_pluginstance *npi)
+{
+ struct ulogd_pluginstance_stack *stack;
+ struct ulogd_pluginstance *pi;
+
+ llist_for_each_entry(stack, &ulogd_pi_stacks, stack_list) {
+ llist_for_each_entry(pi, &stack->list, list) {
+ if (!strcmp(pi->id, npi->id)) {
+ ulogd_log(ULOGD_INFO, "%s instance already "
+ "loaded\n", pi->id);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
static int create_stack_start_instances(struct ulogd_pluginstance_stack *stack)
{
int ret;
@@ -720,11 +738,15 @@ static int create_stack_start_instances(struct ulogd_pluginstance_stack *stack)
if (!pi->plugin->start)
continue;
- ret = pi->plugin->start(pi);
- if (ret < 0) {
- ulogd_log(ULOGD_ERROR, "error during start of `%s'\n",
- pi->id);
- return ret;
+ /* only call start if a plugin with same ID was not started */
+ if (!pluginstance_started(pi)) {
+ ret = pi->plugin->start(pi);
+ if (ret < 0) {
+ ulogd_log(ULOGD_ERROR,
+ "error starting `%s'\n",
+ pi->id);
+ return ret;
+ }
}
}
return 0;