summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-10-09 10:35:14 +0200
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:37 +0200
commitab77a44c31d7940485a84f76c3114bfa2efea4e6 (patch)
tree9d905a493165af3c2ae9229550ec276a3e3e5f2e
parentebf7c8a32ca1edcd02cf95186b477a5d58b531c0 (diff)
Reset key source pointer on error
Also it is specifically not an error if a key pointer already has a source link. This may happen e. g. if a database plugin errors out in it's ->start() routine, having already the source links set. This is what happens: PGSQL: configure NFLOG: configure stack_resolve_keys(stack); PGSQL: start() /* error, back to PsInit */ PGSQL: configure() stack_resolve_keys(stack); /* key->source already set */ Fix it by removing the check in stack_resolve_keys(), also reset key->source correctly on other errors. Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
-rw-r--r--src/plugin.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plugin.c b/src/plugin.c
index b5946d0..e46711e 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -98,6 +98,7 @@ static int
stack_resolve_keys(const struct ulogd_pluginstance_stack *stack)
{
struct ulogd_pluginstance *pi_cur, *pi_src;
+ struct ulogd_key *ikey;
int i = 0;
assert(stack->state == PsConfigured);
@@ -146,29 +147,31 @@ stack_resolve_keys(const struct ulogd_pluginstance_stack *stack)
for (j = 0; j < pi_cur->input.num_keys; j++) {
struct ulogd_key *okey;
- struct ulogd_key *ikey = &pi_cur->input.keys[j];
+
+ ikey = &pi_cur->input.keys[j];
/* skip those marked as 'inactive' by
* pl->configure() */
if (ikey->flags & ULOGD_KEYF_INACTIVE)
continue;
- BUG_ON(ikey->source);
-
okey = find_okey_in_stack(ikey->name, pi_cur, &pi_src);
- if (okey == NULL) {
- if (ikey->flags & ULOGD_KEYF_OPTIONAL)
+ if (!okey) {
+ if (ikey->flags & ULOGD_KEYF_OPTIONAL) {
+ ikey->source = NULL;
continue;
+ }
ulogd_log(ULOGD_ERROR, "cannot find key '%s' in stack\n",
ikey->name);
- return -EINVAL;
+ goto err;
}
if (!key_type_eq(ikey, okey)) {
ulogd_log(ULOGD_FATAL, "type mismatch %s(%s) <-> %s(%s)\n",
ikey->name, pi_cur->id,
okey->name, pi_src->id);
+ goto err;
}
ulogd_log(ULOGD_DEBUG, " %s(%s) -> %s(%s)\n",
@@ -179,6 +182,10 @@ stack_resolve_keys(const struct ulogd_pluginstance_stack *stack)
}
return 0;
+
+err:
+ ikey->source = NULL;
+ return -1;
}
/**