summaryrefslogtreecommitdiff
path: root/lib/dns/dispatch.c
diff options
context:
space:
mode:
authorInternet Software Consortium, Inc <@isc.org>2009-12-26 18:04:05 -0700
committerInternet Software Consortium, Inc <@isc.org>2009-12-26 18:04:05 -0700
commit2d27fb027f207bdec109fad8c9c65f9d6278b3db (patch)
tree114b1faecb63eeee27fb44da040d619cac686d72 /lib/dns/dispatch.c
parent76d4794687ff55c501dc8f09f200494ef1ac429d (diff)
downloadbind9-2d27fb027f207bdec109fad8c9c65f9d6278b3db.tar.gz
9.7.0rc1
Diffstat (limited to 'lib/dns/dispatch.c')
-rw-r--r--lib/dns/dispatch.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c
index e1323055..1d65ce43 100644
--- a/lib/dns/dispatch.c
+++ b/lib/dns/dispatch.c
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dispatch.c,v 1.164 2009/09/01 00:22:26 jinmei Exp $ */
+/* $Id: dispatch.c,v 1.168 2009/12/02 23:15:14 marka Exp $ */
/*! \file */
@@ -778,13 +778,19 @@ new_portentry(dns_dispatch_t *disp, in_port_t port) {
return (portentry);
}
+/*%
+ * The caller must not hold the qid->lock.
+ */
static void
deref_portentry(dns_dispatch_t *disp, dispportentry_t **portentryp) {
dispportentry_t *portentry = *portentryp;
+ dns_qid_t *qid;
REQUIRE(disp->port_table != NULL);
REQUIRE(portentry != NULL && portentry->refs > 0);
+ qid = DNS_QID(disp);
+ LOCK(&qid->lock);
portentry->refs--;
if (portentry->refs == 0) {
ISC_LIST_UNLINK(disp->port_table[portentry->port %
@@ -794,6 +800,7 @@ deref_portentry(dns_dispatch_t *disp, dispportentry_t **portentryp) {
}
*portentryp = NULL;
+ UNLOCK(&qid->lock);
}
/*%
@@ -811,8 +818,9 @@ socket_search(dns_qid_t *qid, isc_sockaddr_t *dest, in_port_t port,
dispsock = ISC_LIST_HEAD(qid->sock_table[bucket]);
while (dispsock != NULL) {
- if (isc_sockaddr_equal(dest, &dispsock->host) &&
- dispsock->portentry->port == port)
+ if (dispsock->portentry != NULL &&
+ dispsock->portentry->port == port &&
+ isc_sockaddr_equal(dest, &dispsock->host))
return (dispsock);
dispsock = ISC_LIST_NEXT(dispsock, blink);
}
@@ -2103,8 +2111,18 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr,
/* Create or adjust buffer pool */
if (mgr->bpool != NULL) {
- isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
- mgr->maxbuffers = maxbuffers;
+ /*
+ * We only increase the maxbuffers to avoid accidental buffer
+ * shortage. Ideally we'd separate the manager-wide maximum
+ * from per-dispatch limits and respect the latter within the
+ * global limit. But at this moment that's deemed to be
+ * overkilling and isn't worth additional implementation
+ * complexity.
+ */
+ if (maxbuffers > mgr->maxbuffers) {
+ isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
+ mgr->maxbuffers = maxbuffers;
+ }
} else {
result = isc_mempool_create(mgr->mctx, buffersize, &mgr->bpool);
if (result != ISC_R_SUCCESS) {