diff options
author | Jeremy Sowden <jeremy@azazel.net> | 2021-11-30 10:55:39 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-11-30 23:06:38 +0100 |
commit | 97fd6fa529330024264e5fa1ee5481a494c47137 (patch) | |
tree | a96c57e32d799d3f73638f5f3b4c7713219c5302 /output | |
parent | 4958b0bf1221bdf3f7e30ff0fd235eb6321d5efb (diff) |
output: DBI: fix deprecation warnings
The DBI output plugin uses some libdbi functions which have been
deprecated in favour of re-entrant equivalents. Switch to the
re-entrant functions.
Remove superfluous `init` declaration.
Add destructor to clean up DBI instance on exit.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'output')
-rw-r--r-- | output/dbi/ulogd_output_DBI.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/output/dbi/ulogd_output_DBI.c b/output/dbi/ulogd_output_DBI.c index 23cc9c8..b4a5bac 100644 --- a/output/dbi/ulogd_output_DBI.c +++ b/output/dbi/ulogd_output_DBI.c @@ -29,6 +29,8 @@ #define DEBUGP(x, args...) #endif +static dbi_inst libdbi_instance; + struct dbi_instance { struct db_instance db_inst; @@ -173,7 +175,6 @@ static int close_db_dbi(struct ulogd_pluginstance *upi) ulogd_log(ULOGD_DEBUG, "dbi: closing connection\n"); dbi_conn_close(pi->dbh); pi->dbh = NULL; - //dbi_shutdown(); return 0; } @@ -195,14 +196,14 @@ static int open_db_dbi(struct ulogd_pluginstance *upi) ulogd_log(ULOGD_ERROR, "Opening connection for db type %s\n", dbtype); - driver = dbi_driver_open(dbtype); + driver = dbi_driver_open_r(dbtype, libdbi_instance); if (driver == NULL) { ulogd_log(ULOGD_ERROR, "unable to load driver for db type %s\n", dbtype); close_db_dbi(upi); return -1; } - pi->dbh = dbi_conn_new(dbtype); + pi->dbh = dbi_conn_new_r(dbtype, libdbi_instance); if (pi->dbh == NULL) { ulogd_log(ULOGD_ERROR, "unable to initialize db type %s\n", dbtype); @@ -316,11 +317,14 @@ static struct ulogd_plugin dbi_plugin = { .version = VERSION, }; -void __attribute__ ((constructor)) init(void); - -void init(void) +void __attribute__ ((constructor)) init(void) { - dbi_initialize(NULL); + dbi_initialize_r(NULL, &libdbi_instance); ulogd_register_plugin(&dbi_plugin); } + +void __attribute__ ((destructor)) fini(void) +{ + dbi_shutdown_r(libdbi_instance); +} |