From 440aaff114607e82aefee56336846611a2e35c9c Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 24 Jan 2013 09:59:26 +0100 Subject: optimize: move lowercasing of hostnames to cache so we save this on each name lookup! --- runtime/nsd_ptcp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'runtime/nsd_ptcp.c') diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c index 630c8e68..c05397a6 100644 --- a/runtime/nsd_ptcp.c +++ b/runtime/nsd_ptcp.c @@ -252,23 +252,21 @@ Abort(nsd_t *pNsd) static rsRetVal FillRemHost(nsd_ptcp_t *pThis, struct sockaddr_storage *pAddr) { - uchar *szHname; - rs_size_t lenHname; + prop_t *fqdn; DEFiRet; ISOBJ_TYPE_assert(pThis, nsd_ptcp); assert(pAddr != NULL); - CHKiRet(dnscacheLookup(pAddr, &szHname, &lenHname, &pThis->remoteIP)); + CHKiRet(dnscacheLookup(pAddr, &fqdn, NULL, &pThis->remoteIP)); /* We now have the names, so now let's allocate memory and store them permanently. * (side note: we may hold on to these values for quite a while, thus we trim their * memory consumption) */ - lenHname++; - if((pThis->pRemHostName = MALLOC(lenHname)) == NULL) + if((pThis->pRemHostName = MALLOC(prop.GetStringLen(fqdn+1))) == NULL) ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); - memcpy(pThis->pRemHostName, szHname, lenHname); + memcpy(pThis->pRemHostName, propGetSzStr(fqdn), prop.GetStringLen(fqdn)+1); finalize_it: RETiRet; -- cgit v1.2.3