summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-03-10 14:46:47 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-03-10 14:46:47 +0100
commit9cc963926bad3de9a78df51a19456f419c34492a (patch)
tree5321d74ead5891f138f6919a81dfd672e91b6a78
parent225aa0e367a604d3891bba13d470bfacc3dfe544 (diff)
downloadrsyslog-9cc963926bad3de9a78df51a19456f419c34492a.tar.gz
rsyslog-9cc963926bad3de9a78df51a19456f419c34492a.tar.xz
rsyslog-9cc963926bad3de9a78df51a19456f419c34492a.zip
bugfix: minor memory leak in omlibdbi (< 1k per instance and run)
also testbench improvement (omlibdbi now also receives a couple of tests if we have a life MySQL server).
-rw-r--r--ChangeLog1
-rw-r--r--plugins/omlibdbi/omlibdbi.c9
-rw-r--r--tests/Makefile.am11
-rwxr-xr-xtests/libdbi-asyn.sh13
-rwxr-xr-xtests/libdbi-basic-vg.sh16
-rwxr-xr-xtests/libdbi-basic.sh13
-rw-r--r--tests/testsuites/libdbi-asyn.conf12
-rw-r--r--tests/testsuites/libdbi-basic.conf9
8 files changed, 83 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 784a8787..320134e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Version 5.7.9 [V5-BETA] (rgerhards), 2011-03-??
- improved testbench
among others, life tests for ommysql (against a test database) have
been added, valgrind-based testing enhanced, ...
+- bugfix: minor memory leak in omlibdbi (< 1k per instance and run)
- bugfix: (regression) omhdfs did no longer compile
- bugfix: omlibdbi did not use password from rsyslog.con
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=203
diff --git a/plugins/omlibdbi/omlibdbi.c b/plugins/omlibdbi/omlibdbi.c
index f49bef42..7fcf9631 100644
--- a/plugins/omlibdbi/omlibdbi.c
+++ b/plugins/omlibdbi/omlibdbi.c
@@ -108,6 +108,11 @@ static void closeConn(instanceData *pData)
BEGINfreeInstance
CODESTARTfreeInstance
closeConn(pData);
+ free(pData->drvrName);
+ free(pData->host);
+ free(pData->usrName);
+ free(pData->pwd);
+ free(pData->dbName);
ENDfreeInstance
@@ -171,7 +176,8 @@ static rsRetVal initConn(instanceData *pData, int bSilent)
errmsg.LogError(0, RS_RET_SUSPENDED, "libdbi error: libdbi or libdbi drivers not present on this system - suspending.");
ABORT_FINALIZE(RS_RET_SUSPENDED);
} else if(iDrvrsLoaded < 0) {
- errmsg.LogError(0, RS_RET_SUSPENDED, "libdbi error: libdbi could not be initialized - suspending.");
+ errmsg.LogError(0, RS_RET_SUSPENDED, "libdbi error: libdbi could not be "
+ "initialized (do you have any dbi drivers installed?) - suspending.");
ABORT_FINALIZE(RS_RET_SUSPENDED);
}
bDbiInitialized = 1; /* we are done for the rest of our existence... */
@@ -367,6 +373,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionlibdbipassword", 0, eCmdHdlrGetWord, NULL, &pwd, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionlibdbidbname", 0, eCmdHdlrGetWord, NULL, &dbName, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr( (uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
+ DBGPRINTF("omlibdbi compiled with version %s loaded, libdbi version %s\n", VERSION, dbi_version());
ENDmodInit
/* vim:set ai:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eb7ad94f..ea6860d5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -63,10 +63,16 @@ TESTS += \
tcp-msgreduc-vg.sh
endif
+
if ENABLE_MYSQL_TESTS
TESTS += \
mysql-basic.sh \
mysql-asyn.sh
+if ENABLE_OMLIBDBI
+TESTS += \
+ libdbi-basic.sh \
+ libdbi-asyn.sh
+endif
if HAVE_VALGRIND
TESTS += \
mysql-basic-vg.sh \
@@ -74,6 +80,7 @@ TESTS += \
endif
endif
+
if ENABLE_IMPTCP
TESTS += \
manyptcp.sh \
@@ -367,6 +374,10 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
resultdata/imuxsock_ccmiddle.log \
testsuites/mysql-truncate.sql \
testsuites/mysql-select-msg.sql \
+ libdbi-basic.sh \
+ testsuites/libdbi-basic.conf \
+ libdbi-asyn.sh \
+ testsuites/libdbi-asyn.conf \
mysql-basic.sh \
mysql-basic-vg.sh \
testsuites/mysql-basic.conf \
diff --git a/tests/libdbi-asyn.sh b/tests/libdbi-asyn.sh
new file mode 100755
index 00000000..0076da9c
--- /dev/null
+++ b/tests/libdbi-asyn.sh
@@ -0,0 +1,13 @@
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[libdbi-asyn.sh\]: asyn test for libdbi functionality
+source $srcdir/diag.sh init
+mysql --user=rsyslog --password=testbench < testsuites/mysql-truncate.sql
+source $srcdir/diag.sh startup libdbi-asyn.conf
+source $srcdir/diag.sh injectmsg 0 50000
+source $srcdir/diag.sh shutdown-when-empty
+source $srcdir/diag.sh wait-shutdown
+# note "-s" is requried to suppress the select "field header"
+mysql -s --user=rsyslog --password=testbench < testsuites/mysql-select-msg.sql > rsyslog.out.log
+source $srcdir/diag.sh seq-check 0 49999
+source $srcdir/diag.sh exit
diff --git a/tests/libdbi-basic-vg.sh b/tests/libdbi-basic-vg.sh
new file mode 100755
index 00000000..75d12857
--- /dev/null
+++ b/tests/libdbi-basic-vg.sh
@@ -0,0 +1,16 @@
+# This file is part of the rsyslog project, released under GPLv3
+# this test is currently not included in the testbench as libdbi
+# itself seems to have a memory leak
+echo ===============================================================================
+echo \[libdbi-basic.sh\]: basic test for libdbi-basic functionality via mysql
+source $srcdir/diag.sh init
+mysql --user=rsyslog --password=testbench < testsuites/mysql-truncate.sql
+source $srcdir/diag.sh startup-vg libdbi-basic.conf
+source $srcdir/diag.sh injectmsg 0 5000
+source $srcdir/diag.sh shutdown-when-empty
+source $srcdir/diag.sh wait-shutdown-vg
+source $srcdir/diag.sh check-exit-vg
+# note "-s" is requried to suppress the select "field header"
+mysql -s --user=rsyslog --password=testbench < testsuites/mysql-select-msg.sql > rsyslog.out.log
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/libdbi-basic.sh b/tests/libdbi-basic.sh
new file mode 100755
index 00000000..a854a565
--- /dev/null
+++ b/tests/libdbi-basic.sh
@@ -0,0 +1,13 @@
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[libdbi-basic.sh\]: basic test for libdbi-basic functionality via mysql
+source $srcdir/diag.sh init
+mysql --user=rsyslog --password=testbench < testsuites/mysql-truncate.sql
+source $srcdir/diag.sh startup libdbi-basic.conf
+source $srcdir/diag.sh injectmsg 0 5000
+source $srcdir/diag.sh shutdown-when-empty
+source $srcdir/diag.sh wait-shutdown
+# note "-s" is requried to suppress the select "field header"
+mysql -s --user=rsyslog --password=testbench < testsuites/mysql-select-msg.sql > rsyslog.out.log
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/libdbi-asyn.conf b/tests/testsuites/libdbi-asyn.conf
new file mode 100644
index 00000000..39b01fbc
--- /dev/null
+++ b/tests/testsuites/libdbi-asyn.conf
@@ -0,0 +1,12 @@
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/omlibdbi/.libs/omlibdbi
+
+$ActionQueueType LinkedList
+
+$ActionLibdbiDriver mysql
+$ActionLibdbiHost 127.0.0.1
+$ActionLibdbiUserName root
+$ActionLibdbiPassword pass
+$ActionLibdbiDBName Syslog
+:msg, contains, "msgnum:" :omlibdbi:
diff --git a/tests/testsuites/libdbi-basic.conf b/tests/testsuites/libdbi-basic.conf
new file mode 100644
index 00000000..212225cc
--- /dev/null
+++ b/tests/testsuites/libdbi-basic.conf
@@ -0,0 +1,9 @@
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/omlibdbi/.libs/omlibdbi
+$ActionLibdbiDriver mysql
+$ActionLibdbiHost 127.0.0.1
+$ActionLibdbiUserName root
+$ActionLibdbiPassword pass
+$ActionLibdbiDBName Syslog
+:msg, contains, "msgnum:" :omlibdbi: