diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-01-24 09:59:26 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-01-24 09:59:26 +0100 |
commit | 440aaff114607e82aefee56336846611a2e35c9c (patch) | |
tree | 25de2deb70d2f1b904bf3cd562c52e55d23c74d0 /runtime/net.c | |
parent | 3668e0085b6c6b89df302c4c390b5bc53b6a6769 (diff) | |
download | rsyslog-440aaff114607e82aefee56336846611a2e35c9c.tar.gz rsyslog-440aaff114607e82aefee56336846611a2e35c9c.tar.bz2 rsyslog-440aaff114607e82aefee56336846611a2e35c9c.zip |
optimize: move lowercasing of hostnames to cache
so we save this on each name lookup!
Diffstat (limited to 'runtime/net.c')
-rw-r--r-- | runtime/net.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/runtime/net.c b/runtime/net.c index 5ec1b0b3..e5d8b4a4 100644 --- a/runtime/net.c +++ b/runtime/net.c @@ -70,6 +70,7 @@ #include "errmsg.h" #include "net.h" #include "dnscache.h" +#include "prop.h" #ifdef OS_SOLARIS # define s6_addr32 _S6_un._S6_u32 @@ -83,6 +84,7 @@ MODULE_TYPE_NOKEEP DEFobjStaticHelpers DEFobjCurrIf(errmsg) DEFobjCurrIf(glbl) +DEFobjCurrIf(prop) /* support for defining allowed TCP and UDP senders. We use the same * structure to implement this (a linked list), but we define two different @@ -1128,8 +1130,7 @@ void debugListenInfo(int fd, char *type) rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN, prop_t **ip) { DEFiRet; - uchar *host; - rs_size_t lenHost; + prop_t *fqdnLowerCase; register uchar *p; int count; int i; @@ -1138,12 +1139,9 @@ rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN assert(pszHost != NULL); assert(pszHostFQDN != NULL); - iRet = dnscacheLookup(f, &host, &lenHost, ip); - /* Convert to lower case */ - for(i = 0 ; i < lenHost ; ++i) { - pszHostFQDN[i] = tolower(host[i]); - } - pszHostFQDN [i] = '\0'; + iRet = dnscacheLookup(f, NULL, &fqdnLowerCase, ip); + strcpy((char*)pszHostFQDN, (char*)propGetSzStr(fqdnLowerCase)); + prop.Destruct(&fqdnLowerCase); if(iRet == RS_RET_INVALID_SOURCE) { strcpy((char*) pszHost, (char*) pszHostFQDN); /* we use whatever was provided as replacement */ @@ -1578,6 +1576,7 @@ BEGINObjClassExit(net, OBJ_IS_LOADABLE_MODULE) /* CHANGE class also in END MACRO CODESTARTObjClassExit(net) /* release objects we no longer need */ objRelease(glbl, CORE_COMPONENT); + objRelease(prop, CORE_COMPONENT); objRelease(errmsg, CORE_COMPONENT); ENDObjClassExit(net) @@ -1590,6 +1589,7 @@ BEGINAbstractObjClassInit(net, 1, OBJ_IS_CORE_MODULE) /* class, version */ /* request objects we use */ CHKiRet(objUse(errmsg, CORE_COMPONENT)); CHKiRet(objUse(glbl, CORE_COMPONENT)); + CHKiRet(objUse(prop, CORE_COMPONENT)); /* set our own handlers */ ENDObjClassInit(net) |