summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2008-11-20 12:49:20 +0100
committerMichael Biebl <biebl@debian.org>2008-11-20 12:49:20 +0100
commitc16d7e48359ded62765f551d05d9b289240a2ec1 (patch)
treed032d278be583fbd6aa65722d5e30122cb158834 /plugins
parent1f6d3725822e3fd676ca66d1b7f841ce2c9c434f (diff)
downloadrsyslog-c16d7e48359ded62765f551d05d9b289240a2ec1.tar.gz
Imported Upstream version 3.18.5upstream/3.18.5
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imfile/imfile.c18
-rw-r--r--plugins/imudp/imudp.c8
-rw-r--r--plugins/imuxsock/imuxsock.c2
-rw-r--r--plugins/ommysql/ommysql.c24
4 files changed, 43 insertions, 9 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index 75e54f0..2df1aaf 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -182,16 +182,19 @@ static void pollFileCancelCleanup(void *pArg)
/* poll a file, need to check file rollover etc. open file if not open */
static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
{
- DEFiRet;
cstr_t *pCStr = NULL;
+ DEFiRet;
ASSERT(pbHadFileData != NULL);
+ /* Note: we must do pthread_cleanup_push() immediately, because the POXIS macros
+ * otherwise do not work if I include the _cleanup_pop() inside an if... -- rgerhards, 2008-08-14
+ */
+ pthread_cleanup_push(pollFileCancelCleanup, &pCStr);
if(pThis->pStrm == NULL) {
CHKiRet(openFile(pThis)); /* open file */
}
- pthread_cleanup_push(pollFileCancelCleanup, &pCStr);
/* loop below will be exited when strmReadLine() returns EOF */
while(1) {
CHKiRet(strmReadLine(pThis->pStrm, &pCStr));
@@ -199,9 +202,18 @@ static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
CHKiRet(enqLine(pThis, pCStr)); /* process line */
rsCStrDestruct(&pCStr); /* discard string (must be done by us!) */
}
- pthread_cleanup_pop(0);
finalize_it:
+ /*EMPTY - just to keep the compiler happy, do NOT remove*/;
+ /* Note: the problem above is that pthread:cleanup_pop() is a macro which
+ * evaluates to something like "} while(0);". So the code would become
+ * "finalize_it: }", that is a label without a statement. The C standard does
+ * not permit this. So we add an empty statement "finalize_it: ; }" and
+ * everybody is happy. Note that without the ;, an error is reported only
+ * on some platforms/compiler versions. -- rgerhards, 2008-08-15
+ */
+ pthread_cleanup_pop(0);
+
if(pCStr != NULL) {
rsCStrDestruct(&pCStr);
}
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index cda794c..81e7d7a 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -242,10 +242,14 @@ CODESTARTafterRun
net.clearAllowedSenders (net.pAllowedSenders_UDP);
net.pAllowedSenders_UDP = NULL;
}
- if(udpLstnSocks != NULL)
+ if(udpLstnSocks != NULL) {
net.closeUDPListenSockets(udpLstnSocks);
- if(pRcvBuf != NULL)
+ udpLstnSocks = NULL;
+ }
+ if(pRcvBuf != NULL) {
free(pRcvBuf);
+ pRcvBuf = NULL;
+ }
ENDafterRun
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index f879803..60ccaff 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -181,7 +181,7 @@ static rsRetVal readSocket(int fd, int bParseHost, int flags)
iRcvd = recv(fd, line, MAXLINE - 1, 0);
dbgprintf("Message from UNIX socket: #%d\n", fd);
if (iRcvd > 0) {
- parseAndSubmitMessage((char*)LocalHostName, line, iRcvd, bParseHost, flags, eFLOWCTL_LIGHT_DELAY);
+ parseAndSubmitMessage((char*)LocalHostName, line, iRcvd, bParseHost, flags, eFLOWCTL_NO_DELAY);
} else if (iRcvd < 0 && errno != EINTR) {
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c
index 0522e31..807351d 100644
--- a/plugins/ommysql/ommysql.c
+++ b/plugins/ommysql/ommysql.c
@@ -44,6 +44,7 @@
#include "ommysql.h"
#include "module-template.h"
#include "errmsg.h"
+#include "cfsysline.h"
MODULE_TYPE_OUTPUT
@@ -55,12 +56,16 @@ DEFobjCurrIf(errmsg)
typedef struct _instanceData {
MYSQL *f_hmysql; /* handle to MySQL */
char f_dbsrv[MAXHOSTNAMELEN+1]; /* IP or hostname of DB server*/
+ unsigned int f_dbsrvPort; /* port of MySQL server */
char f_dbname[_DB_MAXDBLEN+1]; /* DB name */
char f_dbuid[_DB_MAXUNAMELEN+1]; /* DB user */
char f_dbpwd[_DB_MAXPWDLEN+1]; /* DB user's password */
unsigned uLastMySQLErrno; /* last errno returned by MySQL or 0 if all is well */
} instanceData;
+/* config variables */
+static int iSrvPort = 0; /* database server port */
+
BEGINcreateInstance
CODESTARTcreateInstance
@@ -150,7 +155,7 @@ static rsRetVal initMySQL(instanceData *pData, int bSilent)
} else { /* we could get the handle, now on with work... */
/* Connect to database */
if(mysql_real_connect(pData->f_hmysql, pData->f_dbsrv, pData->f_dbuid,
- pData->f_dbpwd, pData->f_dbname, 0, NULL, 0) == NULL) {
+ pData->f_dbpwd, pData->f_dbname, pData->f_dbsrvPort, NULL, 0) == NULL) {
reportDBError(pData, bSilent);
closeMySQL(pData); /* ignore any error we may get */
iRet = RS_RET_SUSPENDED;
@@ -273,6 +278,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
errmsg.LogError(NO_ERRCODE, "Trouble with MySQL connection properties. -MySQL logging disabled");
ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
} else {
+ pData->f_dbsrvPort = (unsigned) iSrvPort; /* set configured port */
pData->f_hmysql = NULL; /* initialize, but connect only on first message (important for queued mode!) */
}
@@ -291,12 +297,24 @@ CODEqueryEtryPt_STD_OMOD_QUERIES
ENDqueryEtryPt
+/* Reset config variables for this module to default values.
+ */
+static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
+{
+ DEFiRet;
+ iSrvPort = 0; /* zero is the default port */
+ RETiRet;
+}
+
BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ /* register our config handlers */
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionommysqlserverport", 0, eCmdHdlrInt, NULL, &iSrvPort, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit
-/*
- * vi:set ai:
+
+/* vi:set ai:
*/