summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-11-18 12:05:51 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2008-11-18 12:05:51 +0100
commit599133164d93afb0dab792dadb8f5d6bc3d68a3f (patch)
tree9a8f791fa21386d3620fb8297e14e1c5eb231a62 /runtime
parenta5417f16044d7d56dbceeea09e25ba3e8c47cc01 (diff)
parent49dcad849e93551d90cd6298a576b67c4ad0c7ef (diff)
downloadrsyslog-599133164d93afb0dab792dadb8f5d6bc3d68a3f.tar.gz
rsyslog-599133164d93afb0dab792dadb8f5d6bc3d68a3f.tar.xz
rsyslog-599133164d93afb0dab792dadb8f5d6bc3d68a3f.zip
Merge branch 'beta'
Conflicts: ChangeLog configure.ac doc/manual.html doc/property_replacer.html
Diffstat (limited to 'runtime')
-rw-r--r--runtime/msg.c10
-rw-r--r--runtime/nsd_ptcp.c13
2 files changed, 20 insertions, 3 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index c030fa45..2e2d41ad 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -2009,7 +2009,10 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
* potential matches over the string.
*/
while(!bFound) {
- if(regexp.regexec(&pTpe->data.field.re, pRes + iOffs, nmatch, pmatch, 0) == 0) {
+ int iREstat;
+ iREstat = regexp.regexec(&pTpe->data.field.re, pRes + iOffs, nmatch, pmatch, 0);
+ dbgprintf("regexec return is %d\n", iREstat);
+ if(iREstat == 0) {
if(pmatch[0].rm_so == -1) {
dbgprintf("oops ... start offset of successful regexec is -1\n");
break;
@@ -2017,6 +2020,8 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
if(iTry == pTpe->data.field.iMatchToUse) {
bFound = 1;
} else {
+ dbgprintf("regex found at offset %d, new offset %d, tries %d\n",
+ iOffs, iOffs + pmatch[0].rm_eo, iTry);
iOffs += pmatch[0].rm_eo;
++iTry;
}
@@ -2024,6 +2029,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
break;
}
}
+ dbgprintf("regex: end search, found %d\n", bFound);
if(!bFound) {
/* we got no match! */
if(pTpe->data.field.nomatchAction != TPL_REGEX_NOMATCH_USE_WHOLE_FIELD) {
@@ -2033,6 +2039,8 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
}
if(pTpe->data.field.nomatchAction == TPL_REGEX_NOMATCH_USE_DFLTSTR)
return "**NO MATCH**";
+ else if(pTpe->data.field.nomatchAction == TPL_REGEX_NOMATCH_USE_ZERO)
+ return "0";
else
return "";
}
diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c
index c3899f83..4cb46380 100644
--- a/runtime/nsd_ptcp.c
+++ b/runtime/nsd_ptcp.c
@@ -365,7 +365,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
netstrm_t *pNewStrm = NULL;
nsd_t *pNewNsd = NULL;
int error, maxs, on = 1;
- int sock;
+ int sock = -1;
int numSocks;
int sockflags;
struct addrinfo hints, *res = NULL, *r;
@@ -410,6 +410,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
(char *)&iOn, sizeof (iOn)) < 0) {
close(sock);
+ sock = -1;
continue;
}
}
@@ -417,6 +418,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0 ) {
dbgprintf("error %d setting tcp socket option\n", errno);
close(sock);
+ sock = -1;
continue;
}
@@ -431,6 +433,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
if(sockflags == -1) {
dbgprintf("error %d setting fcntl(O_NONBLOCK) on tcp socket", errno);
close(sock);
+ sock = -1;
continue;
}
@@ -445,6 +448,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
(char *) &on, sizeof(on)) < 0) {
errmsg.LogError(errno, NO_ERRCODE, "TCP setsockopt(BSDCOMPAT)");
close(sock);
+ sock = -1;
continue;
}
}
@@ -458,6 +462,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
/* TODO: check if *we* bound the socket - else we *have* an error! */
dbgprintf("error %d while binding tcp socket", errno);
close(sock);
+ sock = -1;
continue;
}
@@ -472,6 +477,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
if(listen(sock, 32) < 0) {
dbgprintf("tcp listen error %d, suspending\n", errno);
close(sock);
+ sock = -1;
continue;
}
}
@@ -482,13 +488,14 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*),
*/
CHKiRet(pNS->Drvr.Construct(&pNewNsd));
CHKiRet(pNS->Drvr.SetSock(pNewNsd, sock));
+ sock = -1;
CHKiRet(pNS->Drvr.SetMode(pNewNsd, netstrms.GetDrvrMode(pNS)));
CHKiRet(pNS->Drvr.SetAuthMode(pNewNsd, netstrms.GetDrvrAuthMode(pNS)));
CHKiRet(pNS->Drvr.SetPermPeers(pNewNsd, netstrms.GetDrvrPermPeers(pNS)));
CHKiRet(netstrms.CreateStrm(pNS, &pNewStrm));
pNewStrm->pDrvrData = (nsd_t*) pNewNsd;
- CHKiRet(fAddLstn(pUsr, pNewStrm));
pNewNsd = NULL;
+ CHKiRet(fAddLstn(pUsr, pNewStrm));
pNewStrm = NULL;
++numSocks;
}
@@ -507,6 +514,8 @@ finalize_it:
freeaddrinfo(res);
if(iRet != RS_RET_OK) {
+ if(sock != -1)
+ close(sock);
if(pNewStrm != NULL)
netstrm.Destruct(&pNewStrm);
if(pNewNsd != NULL)