From: Mark Andrews Date: Mon, 25 Nov 2019 00:38:09 +0000 (+1100) Subject: move maxbuffers test to allocate_udp_buffer X-Git-Tag: v9.15.7~70^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26a93d77aa17bea5e0a67623558cd3cdcf10009b;p=thirdparty%2Fbind9.git move maxbuffers test to allocate_udp_buffer --- diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 2e534d26c3b..c70ee9fa251 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -915,6 +915,10 @@ allocate_udp_buffer(dns_dispatch_t *disp) { void *temp; LOCK(&disp->mgr->buffer_lock); + if (disp->mgr->buffers >= disp->mgr->maxbuffers) { + UNLOCK(&disp->mgr->buffer_lock); + return (NULL); + } bpool = disp->mgr->bpool; disp->mgr->buffers++; UNLOCK(&disp->mgr->buffer_lock); @@ -1500,15 +1504,6 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { if (disp->recv_pending != 0 && dispsock == NULL) return (ISC_R_SUCCESS); - if (disp->socktype == isc_sockettype_udp) { - LOCK(&disp->mgr->buffer_lock); - if (disp->mgr->buffers >= disp->mgr->maxbuffers) { - UNLOCK(&disp->mgr->buffer_lock); - return (ISC_R_NOMEMORY); - } - UNLOCK(&disp->mgr->buffer_lock); - } - if ((disp->attributes & DNS_DISPATCHATTR_EXCLUSIVE) != 0 && dispsock == NULL) return (ISC_R_SUCCESS);