Compare commits

...
6 changed files with 42 additions and 55 deletions
+3 -1
View File
@@ -216,7 +216,9 @@ dns_badcache_find(dns_badcache_t *bc, const dns_name_t *name,
REQUIRE(name != NULL); REQUIRE(name != NULL);
REQUIRE(now != NULL); REQUIRE(now != NULL);
LOCK(&bc->lock); if (isc_mutex_trylock(&bc->lock) != ISC_R_SUCCESS) {
return (false);
}
/* /*
* XXXMUKS: dns_name_equal() is expensive as it does a * XXXMUKS: dns_name_equal() is expensive as it does a
-30
View File
@@ -558,36 +558,6 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
else else
count = count2; count = count2;
/* Loop unrolled for performance */
while (ISC_LIKELY(count > 3)) {
chdiff = (int)maptolower[label1[0]] -
(int)maptolower[label2[0]];
if (chdiff != 0) {
*orderp = chdiff;
goto done;
}
chdiff = (int)maptolower[label1[1]] -
(int)maptolower[label2[1]];
if (chdiff != 0) {
*orderp = chdiff;
goto done;
}
chdiff = (int)maptolower[label1[2]] -
(int)maptolower[label2[2]];
if (chdiff != 0) {
*orderp = chdiff;
goto done;
}
chdiff = (int)maptolower[label1[3]] -
(int)maptolower[label2[3]];
if (chdiff != 0) {
*orderp = chdiff;
goto done;
}
count -= 4;
label1 += 4;
label2 += 4;
}
while (ISC_LIKELY(count-- > 0)) { while (ISC_LIKELY(count-- > 0)) {
chdiff = (int)maptolower[*label1++] - chdiff = (int)maptolower[*label1++] -
(int)maptolower[*label2++]; (int)maptolower[*label2++];
+1 -1
View File
@@ -172,7 +172,7 @@
/* Number of hash buckets for zone counters */ /* Number of hash buckets for zone counters */
#ifndef RES_DOMAIN_BUCKETS #ifndef RES_DOMAIN_BUCKETS
#define RES_DOMAIN_BUCKETS 523 #define RES_DOMAIN_BUCKETS 2047
#endif #endif
#define RES_NOBUCKET 0xffffffff #define RES_NOBUCKET 0xffffffff
+22 -19
View File
@@ -185,6 +185,7 @@ struct isc__mempool {
ISC_LINK(isc__mempool_t) link; /*%< next pool in this mem context */ ISC_LINK(isc__mempool_t) link; /*%< next pool in this mem context */
/*%< optionally locked from here down */ /*%< optionally locked from here down */
element *items; /*%< low water item list */ element *items; /*%< low water item list */
element *fitems;
size_t size; /*%< size of each item on this pool */ size_t size; /*%< size of each item on this pool */
unsigned int maxalloc; /*%< max number of items allowed */ unsigned int maxalloc; /*%< max number of items allowed */
unsigned int allocated; /*%< # of items currently given out */ unsigned int allocated; /*%< # of items currently given out */
@@ -1572,6 +1573,7 @@ isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
mpctx->name[0] = 0; mpctx->name[0] = 0;
#endif #endif
mpctx->items = NULL; mpctx->items = NULL;
mpctx->fitems = NULL;
*mpctxp = (isc_mempool_t *)mpctx; *mpctxp = (isc_mempool_t *)mpctx;
@@ -1634,17 +1636,15 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
* Return any items on the free list * Return any items on the free list
*/ */
MCTXLOCK(mctx); MCTXLOCK(mctx);
while (mpctx->items != NULL) { while (mpctx->fitems != NULL) {
INSIST(mpctx->freecount > 0); item = mpctx->fitems;
mpctx->freecount--; mpctx->fitems = item->next;
item = mpctx->items;
mpctx->items = item->next;
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) { if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
mem_putunlocked(mctx, item, mpctx->size); mem_putunlocked(mctx, item, mpctx->size * (mpctx->fillcount + 1));
} else { } else {
mem_putstats(mctx, item, mpctx->size); mem_putstats(mctx, item, mpctx->size * (mpctx->fillcount + 1));
mem_put(mctx, item, mpctx->size); mem_put(mctx, item, mpctx->size * (mpctx->fillcount + 1));
} }
} }
MCTXUNLOCK(mctx); MCTXUNLOCK(mctx);
@@ -1707,16 +1707,19 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
* here and fill up our free list. * here and fill up our free list.
*/ */
MCTXLOCK(mctx); MCTXLOCK(mctx);
for (i = 0; i < mpctx->fillcount; i++) { element *fitem;
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) { if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
item = mem_getunlocked(mctx, mpctx->size); fitem = mem_getunlocked(mctx, (mpctx->fillcount+1) * mpctx->size);
} else { } else {
item = mem_get(mctx, mpctx->size); fitem = mem_get(mctx, (mpctx->fillcount+1) * mpctx->size);
if (item != NULL) if (fitem != NULL) {
mem_getstats(mctx, mpctx->size); mem_getstats(mctx, mpctx->size);
} }
if (ISC_UNLIKELY(item == NULL)) }
break; fitem->next = mpctx->fitems;
mpctx->fitems = fitem;
for (i = 1; i < mpctx->fillcount+1; i++) {
item = (element*) (((char*) fitem) + i*mpctx->size);
item->next = mpctx->items; item->next = mpctx->items;
mpctx->items = item; mpctx->items = item;
mpctx->freecount++; mpctx->freecount++;
@@ -1783,7 +1786,7 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
/* /*
* If our free list is full, return this to the mctx directly. * If our free list is full, return this to the mctx directly.
*/ */
if (mpctx->freecount >= mpctx->freemax) { /* if (mpctx->freecount >= mpctx->freemax) {
MCTXLOCK(mctx); MCTXLOCK(mctx);
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) { if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
mem_putunlocked(mctx, mem, mpctx->size); mem_putunlocked(mctx, mem, mpctx->size);
@@ -1795,7 +1798,7 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
if (mpctx->lock != NULL) if (mpctx->lock != NULL)
UNLOCK(mpctx->lock); UNLOCK(mpctx->lock);
return; return;
} } */
/* /*
* Otherwise, attach it to our free list and bump the counter. * Otherwise, attach it to our free list and bump the counter.
+13 -3
View File
@@ -1190,7 +1190,11 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
finished = true; finished = true;
task->state = task_state_done; task->state = task_state_done;
} else { } else {
task->state = task_state_idle; /* It might be paused */
if (task->state ==
task_state_running) {
task->state = task_state_idle;
}
} }
done = true; done = true;
} else if (dispatch_count >= task->quantum) { } else if (dispatch_count >= task->quantum) {
@@ -1205,8 +1209,14 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
* so the minimum quantum is one. * so the minimum quantum is one.
*/ */
XTRACE("quantum"); XTRACE("quantum");
task->state = task_state_ready; if (task->state == task_state_running) {
requeue = true; /*
* We requeue only if it's
* not paused.
*/
task->state = task_state_ready;
requeue = true;
}
done = true; done = true;
} }
} while (!done); } while (!done);
+2
View File
@@ -5819,6 +5819,8 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
ns_client_killoldestquery(client); ns_client_killoldestquery(client);
} }
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
/* Don't add this to badcache */
client->attributes |= NS_CLIENTATTR_NOSETFC;
return (result); return (result);
} }