diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-03-12 17:00:21 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-03-12 17:00:21 +0100 |
commit | f90675f33f33b8a83046f8a8462dd8dbe7648a4a (patch) | |
tree | f695e6371b52141de4c4ce2295b317a1e487e7b3 /runtime | |
parent | 14d415e4a84e2c08df1b23a86959f0d9b0006687 (diff) | |
parent | 74e09afd6db56f6e23c965f0949cfb9979928f13 (diff) | |
download | rsyslog-f90675f33f33b8a83046f8a8462dd8dbe7648a4a.tar.gz rsyslog-f90675f33f33b8a83046f8a8462dd8dbe7648a4a.tar.xz rsyslog-f90675f33f33b8a83046f8a8462dd8dbe7648a4a.zip |
Merge branch 'v5-stable-newstats' into v5-devel
Conflicts:
ChangeLog
action.c
configure.ac
doc/imuxsock.html
doc/manual.html
runtime/queue.c
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/net.c | 54 | ||||
-rw-r--r-- | runtime/net.h | 6 | ||||
-rw-r--r-- | runtime/queue.c | 9 | ||||
-rw-r--r-- | runtime/queue.h | 1 | ||||
-rw-r--r-- | runtime/ruleset.c | 5 | ||||
-rw-r--r-- | runtime/wti.c | 2 | ||||
-rw-r--r-- | runtime/wtp.c | 2 |
7 files changed, 74 insertions, 5 deletions
diff --git a/runtime/net.c b/runtime/net.c index 4781739f..1264b2cb 100644 --- a/runtime/net.c +++ b/runtime/net.c @@ -12,7 +12,7 @@ * long term, but it is good to have it out of syslogd.c. Maybe this here is * an interim location ;) * - * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH. * * rgerhards, 2008-04-16: I changed this code to LGPL today. I carefully analyzed * that it does not borrow code from the original sysklogd and that I have @@ -54,6 +54,9 @@ #include <fnmatch.h> #include <fcntl.h> #include <unistd.h> +#include <ifaddrs.h> +#include <sys/types.h> +#include <arpa/inet.h> #include "syslogd-types.h" #include "module-template.h" @@ -1581,6 +1584,54 @@ finalize_it: } +/* return the IP address (IPv4/6) for the provided interface. Returns + * RS_RET_NOT_FOUND if interface can not be found in interface list. + * The family must be correct (AF_INET vs. AF_INET6, AF_UNSPEC means + * either of *these two*). + * The function re-queries the interface list (at least in theory). + * However, it caches entries in order to avoid too-frequent requery. + * rgerhards, 2012-03-06 + */ +static rsRetVal +getIFIPAddr(uchar *szif, int family, uchar *pszbuf, int lenBuf) +{ + struct ifaddrs * ifaddrs = NULL; + struct ifaddrs * ifa; + void * pAddr; + DEFiRet; + + if(getifaddrs(&ifaddrs) != 0) { + ABORT_FINALIZE(RS_RET_ERR); + } + + for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { + if(strcmp(ifa->ifa_name, (char*)szif)) + continue; + if( (family == AF_INET6 || family == AF_UNSPEC) + && ifa->ifa_addr->sa_family == AF_INET6) { + pAddr = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr; + inet_ntop(AF_INET6, pAddr, (char*)pszbuf, lenBuf); + break; + } else if(/* (family == AF_INET || family == AF_UNSPEC) + &&*/ ifa->ifa_addr->sa_family == AF_INET) { + pAddr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; + inet_ntop(AF_INET, pAddr, (char*)pszbuf, lenBuf); + break; + } + } + + if(ifaddrs != NULL) + freeifaddrs(ifaddrs); + + if(ifa == NULL) + iRet = RS_RET_NOT_FOUND; + +finalize_it: + RETiRet; + +} + + /* queryInterface function * rgerhards, 2008-03-05 */ @@ -1612,6 +1663,7 @@ CODESTARTobjQueryInterface(net) pIf->PermittedPeerWildcardMatch = PermittedPeerWildcardMatch; pIf->CmpHost = CmpHost; pIf->HasRestrictions = HasRestrictions; + pIf->GetIFIPAddr = getIFIPAddr; /* data members */ pIf->pACLAddHostnameOnFail = &ACLAddHostnameOnFail; pIf->pACLDontResolve = &ACLDontResolve; diff --git a/runtime/net.h b/runtime/net.h index 101ce79d..1b41c81c 100644 --- a/runtime/net.h +++ b/runtime/net.h @@ -1,6 +1,6 @@ /* Definitions for network-related stuff. * - * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH. * * This file is part of the rsyslog runtime library. * @@ -151,11 +151,13 @@ BEGINinterface(net) /* name must also be changed in ENDinterface macro! */ /* v6 interface additions - 2009-11-16 */ rsRetVal (*HasRestrictions)(uchar *, int *bHasRestrictions); int (*isAllowedSender2)(uchar *pszType, struct sockaddr *pFrom, const char *pszFromHost, int bChkDNS); + /* v7 interface additions - 2012-03-06 */ + rsRetVal (*GetIFIPAddr)(uchar *szif, int family, uchar *pszbuf, int lenBuf); /* data members - these should go away over time... TODO */ int *pACLAddHostnameOnFail; /* add hostname to acl when DNS resolving has failed */ int *pACLDontResolve; /* add hostname to acl instead of resolving it to IP(s) */ ENDinterface(net) -#define netCURR_IF_VERSION 6 /* increment whenever you change the interface structure! */ +#define netCURR_IF_VERSION 7 /* increment whenever you change the interface structure! */ /* prototypes */ PROTOTYPEObj(net); diff --git a/runtime/queue.c b/runtime/queue.c index 56d05571..fa2ed615 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -1842,6 +1842,8 @@ qqueueChkStopWrkrDA(qqueue_t *pThis) { DEFiRet; + /*DBGPRINTF("XXXX: chkStopWrkrDA called, low watermark %d, log Size %d, phys Size %d, bEnqOnly %d\n", + pThis->iLowWtrMrk, getLogicalQueueSize(pThis), getPhysicalQueueSize(pThis), pThis->bEnqOnly);*/ if(pThis->bEnqOnly) { iRet = RS_RET_TERMINATE_WHEN_IDLE; } @@ -1862,6 +1864,8 @@ static rsRetVal ChkStopWrkrReg(qqueue_t *pThis) { DEFiRet; + /*DBGPRINTF("XXXX: chkStopWrkrReg called, low watermark %d, log Size %d, phys Size %d, bEnqOnly %d\n", + pThis->iLowWtrMrk, getLogicalQueueSize(pThis), getPhysicalQueueSize(pThis), pThis->bEnqOnly);*/ if(pThis->bEnqOnly) { iRet = RS_RET_TERMINATE_NOW; } else if(pThis->pqParent != NULL) { @@ -1898,6 +1902,7 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */ int wrk; uchar *qName; size_t lenBuf; + int iQueueSizeSave; ASSERT(pThis != NULL); @@ -1979,8 +1984,11 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */ qName = obj.GetName((obj_t*)pThis); CHKiRet(statsobj.Construct(&pThis->statsobj)); CHKiRet(statsobj.SetName(pThis->statsobj, qName)); + /* we need to save the queue size, as the stats module initializes it to 0! */ + iQueueSizeSave = pThis->iQueueSize; CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("size"), ctrType_Int, &pThis->iQueueSize)); + pThis->iQueueSize = iQueueSizeSave; STATSCOUNTER_INIT(pThis->ctrEnqueued, pThis->mutCtrEnqueued); CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("enqueued"), @@ -2491,6 +2499,7 @@ DEFpropSetMeth(qqueue, iLowWtrMrk, int) DEFpropSetMeth(qqueue, iDiscardMrk, int) DEFpropSetMeth(qqueue, iFullDlyMrk, int) DEFpropSetMeth(qqueue, iDiscardSeverity, int) +DEFpropSetMeth(qqueue, iLightDlyMrk, int) DEFpropSetMeth(qqueue, bIsDA, int) DEFpropSetMeth(qqueue, iMinMsgsPerWrkr, int) DEFpropSetMeth(qqueue, bSaveOnShutdown, int) diff --git a/runtime/queue.h b/runtime/queue.h index 06a58229..dbd6f249 100644 --- a/runtime/queue.h +++ b/runtime/queue.h @@ -201,6 +201,7 @@ PROTOTYPEpropSetMeth(qqueue, toQShutdown, long); PROTOTYPEpropSetMeth(qqueue, toActShutdown, long); PROTOTYPEpropSetMeth(qqueue, toWrkShutdown, long); PROTOTYPEpropSetMeth(qqueue, toEnq, long); +PROTOTYPEpropSetMeth(qqueue, iLightDlyMrk, int); PROTOTYPEpropSetMeth(qqueue, iHighWtrMrk, int); PROTOTYPEpropSetMeth(qqueue, iLowWtrMrk, int); PROTOTYPEpropSetMeth(qqueue, iDiscardMrk, int); diff --git a/runtime/ruleset.c b/runtime/ruleset.c index 5ee2a55a..69968a52 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -500,6 +500,7 @@ debugPrintAll(void) static rsRetVal rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal) { + uchar *rulesetMainQName; DEFiRet; if(pCurrRuleset == NULL) { @@ -518,7 +519,9 @@ rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal) FINALIZE; /* if it is turned off, we do not need to change anything ;) */ dbgprintf("adding a ruleset-specific \"main\" queue"); - CHKiRet(createMainQueue(&pCurrRuleset->pQueue, UCHAR_CONSTANT("ruleset"))); + rulesetMainQName = (pCurrRuleset->pszName == NULL)? UCHAR_CONSTANT("ruleset") : + pCurrRuleset->pszName; + CHKiRet(createMainQueue(&pCurrRuleset->pQueue, rulesetMainQName)); finalize_it: RETiRet; diff --git a/runtime/wti.c b/runtime/wti.c index 9e781341..e44086af 100644 --- a/runtime/wti.c +++ b/runtime/wti.c @@ -318,6 +318,8 @@ wtiWorker(wti_t *pThis) } else if(localRet == RS_RET_IDLE) { if(terminateRet == RS_RET_TERMINATE_WHEN_IDLE || bInactivityTOOccured) { d_pthread_mutex_unlock(pWtp->pmutUsr); + dbgoprint((obj_t*) pThis, "terminating worker terminateRet=%d, bInactivityTOOccured=%d\n", + terminateRet, bInactivityTOOccured); break; /* end of loop */ } doIdleProcessing(pThis, pWtp, &bInactivityTOOccured); diff --git a/runtime/wtp.c b/runtime/wtp.c index e615fb19..a53a9888 100644 --- a/runtime/wtp.c +++ b/runtime/wtp.c @@ -309,7 +309,7 @@ wtpWrkrExecCleanup(wti_t *pWti) wtiSetState(pWti, WRKTHRD_STOPPED); ATOMIC_DEC(&pThis->iCurNumWrkThrd, &pThis->mutCurNumWrkThrd); - DBGPRINTF("%s: Worker thread %lx, terminated, um workers now %d\n", + DBGPRINTF("%s: Worker thread %lx, terminated, num workers now %d\n", wtpGetDbgHdr(pThis), (unsigned long) pWti, ATOMIC_FETCH_32BIT(&pThis->iCurNumWrkThrd, &pThis->mutCurNumWrkThrd)); |