summaryrefslogtreecommitdiffstats
path: root/plugins/ommysql
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-30 13:07:44 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-30 13:07:44 +0000
commit61b10104612b3d776399f853f399e64ffe175e65 (patch)
treea6653e9e25d3da57451a699a2be9780eadf42da8 /plugins/ommysql
parent91b5178c124417b419854cae35204b6742605af5 (diff)
downloadrsyslog-61b10104612b3d776399f853f399e64ffe175e65.tar.gz
rsyslog-61b10104612b3d776399f853f399e64ffe175e65.tar.xz
rsyslog-61b10104612b3d776399f853f399e64ffe175e65.zip
- changed the ommysql output plugin so that the (lengthy) connection
initialization now takes place in message processing. This works much better with the new queued action mode (fast startup) - fixed a newly introduced bug that caused output module's doAction entry point to be called on more than one thread under some circumstances
Diffstat (limited to 'plugins/ommysql')
-rw-r--r--plugins/ommysql/ommysql.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c
index 107419a5..2c79e363 100644
--- a/plugins/ommysql/ommysql.c
+++ b/plugins/ommysql/ommysql.c
@@ -78,7 +78,7 @@ ENDisCompatibleWithFeature
*/
static void closeMySQL(instanceData *pData)
{
- assert(pData != NULL);
+ ASSERT(pData != NULL);
if(pData->f_hmysql != NULL) { /* just to be on the safe side... */
mysql_server_end();
@@ -113,7 +113,7 @@ static void reportDBError(instanceData *pData, int bSilent)
char errMsg[512];
unsigned uMySQLErrno;
- assert(pData != NULL);
+ ASSERT(pData != NULL);
/* output log message */
errno = 0;
@@ -143,8 +143,8 @@ static rsRetVal initMySQL(instanceData *pData, int bSilent)
{
DEFiRet;
- assert(pData != NULL);
- assert(pData->f_hmysql == NULL);
+ ASSERT(pData != NULL);
+ ASSERT(pData->f_hmysql == NULL);
pData->f_hmysql = mysql_init(NULL);
if(pData->f_hmysql == NULL) {
@@ -160,7 +160,7 @@ static rsRetVal initMySQL(instanceData *pData, int bSilent)
}
}
- return iRet;
+ RETiRet;
}
@@ -172,8 +172,13 @@ rsRetVal writeMySQL(uchar *psz, instanceData *pData)
{
DEFiRet;
- assert(psz != NULL);
- assert(pData != NULL);
+ ASSERT(psz != NULL);
+ ASSERT(pData != NULL);
+
+ /* see if we are ready to proceed */
+ if(pData->f_hmysql == NULL) {
+ CHKiRet(initMySQL(pData, 0));
+ }
/* try insert */
if(mysql_query(pData->f_hmysql, (char*)psz)) {
@@ -193,7 +198,7 @@ finalize_it:
pData->uLastMySQLErrno = 0; /* reset error for error supression */
}
- return iRet;
+ RETiRet;
}
@@ -273,7 +278,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
logerror("Trouble with MySQL connection properties. -MySQL logging disabled");
ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
} else {
- CHKiRet(initMySQL(pData, 0));
+ pData->f_hmysql = NULL; /* initialize, but connect only on first message (important for queued mode!) */
}
CODE_STD_FINALIZERparseSelectorAct