summaryrefslogtreecommitdiff
path: root/plugins/omlibdbi/omlibdbi.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/omlibdbi/omlibdbi.c')
-rw-r--r--plugins/omlibdbi/omlibdbi.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/plugins/omlibdbi/omlibdbi.c b/plugins/omlibdbi/omlibdbi.c
index 6e27ad2..c203b4a 100644
--- a/plugins/omlibdbi/omlibdbi.c
+++ b/plugins/omlibdbi/omlibdbi.c
@@ -10,7 +10,7 @@
*
* File begun on 2008-02-14 by RGerhards (extracted from syslogd.c)
*
- * Copyright 2008-2012 Adiscon GmbH.
+ * Copyright 2008-2013 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -50,6 +50,9 @@
#include "errmsg.h"
#include "conf.h"
+#undef HAVE_DBI_TXSUPP
+#warning transaction support disabled in v8 -- TODO: reenable
+
MODULE_TYPE_OUTPUT
MODULE_TYPE_NOKEEP
MODULE_CNFNAME("omlibdbi")
@@ -73,6 +76,10 @@ typedef struct _instanceData {
int txSupport; /* transaction support */
} instanceData;
+typedef struct wrkrInstanceData {
+ instanceData *pData;
+} wrkrInstanceData_t;
+
typedef struct configSettings_s {
uchar *dbiDrvrDir; /* global: where do the dbi drivers reside? */
uchar *drvrName; /* driver to use */
@@ -94,6 +101,8 @@ static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current l
static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current exec process */
static int bLegacyCnfModGlobalsPermitted;/* are legacy module-global config parameters permitted? */
+static pthread_mutex_t mutDoAct = PTHREAD_MUTEX_INITIALIZER;
+
/* tables for interfacing with the v6 config system */
/* module-global parameters */
@@ -157,6 +166,10 @@ BEGINcreateInstance
CODESTARTcreateInstance
ENDcreateInstance
+BEGINcreateWrkrInstance
+CODESTARTcreateWrkrInstance
+ENDcreateWrkrInstance
+
BEGINisCompatibleWithFeature
CODESTARTisCompatibleWithFeature
@@ -187,6 +200,9 @@ CODESTARTfreeInstance
free(pData->dbName);
ENDfreeInstance
+BEGINfreeWrkrInstance
+CODESTARTfreeWrkrInstance
+ENDfreeWrkrInstance
BEGINdbgPrintInstInfo
CODESTARTdbgPrintInstInfo
@@ -326,22 +342,26 @@ finalize_it:
BEGINtryResume
CODESTARTtryResume
- if(pData->conn == NULL) {
- iRet = initConn(pData, 1);
+ if(pWrkrData->pData->conn == NULL) {
+ iRet = initConn(pWrkrData->pData, 1);
}
ENDtryResume
/* transaction support 2013-03 */
BEGINbeginTransaction
CODESTARTbeginTransaction
- if(pData->conn == NULL) {
- CHKiRet(initConn(pData, 0));
+ if(pWrkrData->pData->conn == NULL) {
+ CHKiRet(initConn(pWrkrData->pData, 0));
}
# if HAVE_DBI_TXSUPP
if (pData->txSupport == 1) {
if (dbi_conn_transaction_begin(pData->conn) != 0) {
- dbgprintf("libdbi server error: begin transaction not successful\n");
- iRet = RS_RET_SUSPENDED;
+ const char *emsg;
+ dbi_conn_error(pData->conn, &emsg);
+ dbgprintf("libdbi server error: begin transaction "
+ "not successful: %s\n", emsg);
+ closeConn(pData);
+ ABORT_FINALIZE(RS_RET_SUSPENDED);
}
}
# endif
@@ -351,13 +371,15 @@ ENDbeginTransaction
BEGINdoAction
CODESTARTdoAction
- CHKiRet(writeDB(ppString[0], pData));
+ pthread_mutex_lock(&mutDoAct);
+ CHKiRet(writeDB(ppString[0], pWrkrData->pData));
# if HAVE_DBI_TXSUPP
if (pData->txSupport == 1) {
iRet = RS_RET_DEFER_COMMIT;
}
# endif
finalize_it:
+ pthread_mutex_unlock(&mutDoAct);
ENDdoAction
/* transaction support 2013-03 */
@@ -365,7 +387,11 @@ BEGINendTransaction
CODESTARTendTransaction
# if HAVE_DBI_TXSUPP
if (dbi_conn_transaction_commit(pData->conn) != 0) {
- dbgprintf("libdbi server error: transaction not committed\n");
+ const char *emsg;
+ dbi_conn_error(pData->conn, &emsg);
+ dbgprintf("libdbi server error: transaction not committed: %s\n",
+ emsg);
+ closeConn(pData);
iRet = RS_RET_SUSPENDED;
}
# endif
@@ -544,6 +570,7 @@ ENDmodExit
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
+CODEqueryEtryPt_STD_OMOD8_QUERIES
CODEqueryEtryPt_STD_CONF2_QUERIES
CODEqueryEtryPt_STD_CONF2_setModCnf_QUERIES
CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES