summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-10-09 10:16:53 +0200
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:37 +0200
commitebf7c8a32ca1edcd02cf95186b477a5d58b531c0 (patch)
tree4b3b15302a617ba9b1493c4b6c1e31dfcc28c4fb
parentc5a9e0ec391941ae55c5a022961910ae57b4518a (diff)
db: add consistency check to db_column
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
-rw-r--r--include/ulogd/db.h3
-rw-r--r--src/db.c13
2 files changed, 12 insertions, 4 deletions
diff --git a/include/ulogd/db.h b/include/ulogd/db.h
index 4846f30..f237426 100644
--- a/include/ulogd/db.h
+++ b/include/ulogd/db.h
@@ -40,6 +40,9 @@ struct db_row {
struct db_column {
struct ulogd_key *key;
+
+ /* just handy for debugging, may be removed later */
+ int num;
};
#define DB_F_OPEN 0x0001
diff --git a/src/db.c b/src/db.c
index 2ac79d9..0aa009e 100644
--- a/src/db.c
+++ b/src/db.c
@@ -170,6 +170,8 @@ err_rollback:
static int
db_alloc_columns(struct db_instance *di, size_t cols)
{
+ int i;
+
if (!di)
return -1;
@@ -179,6 +181,9 @@ db_alloc_columns(struct db_instance *di, size_t cols)
return -1;
}
+ for (i = 0; i < cols; i++)
+ di->col[i].num = i;
+
return 0;
}
@@ -676,6 +681,10 @@ ulogd_db_interp(struct ulogd_pluginstance *pi, unsigned *flags)
if (blackhole_ce(pi))
return ULOGD_IRET_OK;
+ /* reset key pointers */
+ for (i = 0; i < di->num_cols; i++)
+ di->col[i].key = NULL;
+
for (i = 0; i < pi->input.num_keys; i++) {
key = &in[i];
@@ -684,7 +693,6 @@ ulogd_db_interp(struct ulogd_pluginstance *pi, unsigned *flags)
BUG_ON(!key->col);
BUG_ON(key->col->key);
-
key->col->key = key_src(key);
}
@@ -704,9 +712,6 @@ ulogd_db_interp(struct ulogd_pluginstance *pi, unsigned *flags)
memcpy(&row->value[i], &key->val, sizeof(struct ulogd_value));
}
- /* reset key pointers */
- memset(di->col, 0, di->num_cols * sizeof(struct db_column));
-
if (db_row_add(pi, row) < 0)
return ULOGD_IRET_OK;