diff options
author | Eric Leblond <eric@inl.fr> | 2010-09-19 19:55:41 +0200 |
---|---|---|
committer | Eric Leblond <eric@inl.fr> | 2010-09-22 01:36:42 +0200 |
commit | 58e654e1deda9d230dfb1d64bec773233a19ef84 (patch) | |
tree | b744ced548e87a5053fa33bd6e1d77523ebd8f3a /util | |
parent | c14e78d68e7148892268b4eed2d6e1481095a5ea (diff) |
DB output: fix crash in SIGHUP handling
This patch fixes the handling of SIGHUP when a SQL plugin is used. A
freed structure was previoulsy used to build the request and this was
leading to a crash.
Diffstat (limited to 'util')
-rw-r--r-- | util/db.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -190,18 +190,12 @@ int ulogd_db_start(struct ulogd_pluginstance *upi) return ret; } -int ulogd_db_stop(struct ulogd_pluginstance *upi) +static int ulogd_db_instance_stop(struct ulogd_pluginstance *upi) { struct db_instance *di = (struct db_instance *) upi->private; ulogd_log(ULOGD_NOTICE, "stopping\n"); di->driver->close_db(upi); - /* try to free our dynamically allocated input key array */ - if (upi->input.keys) { - free(upi->input.keys); - upi->input.keys = NULL; - } - /* try to free the buffer for insert statement */ if (di->stmt) { free(di->stmt); @@ -211,6 +205,19 @@ int ulogd_db_stop(struct ulogd_pluginstance *upi) return 0; } +int ulogd_db_stop(struct ulogd_pluginstance *upi) +{ + ulogd_db_instance_stop(upi); + + /* try to free our dynamically allocated input key array */ + if (upi->input.keys) { + free(upi->input.keys); + upi->input.keys = NULL; + } + + return 0; +} + static int _init_reconnect(struct ulogd_pluginstance *upi) { @@ -356,7 +363,7 @@ void ulogd_db_signal(struct ulogd_pluginstance *upi, int signal) switch (signal) { case SIGHUP: /* reopen database connection */ - ulogd_db_stop(upi); + ulogd_db_instance_stop(upi); ulogd_db_start(upi); break; default: |