]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
move maxbuffers test to allocate_udp_buffer
authorMark Andrews <marka@isc.org>
Mon, 25 Nov 2019 00:38:09 +0000 (11:38 +1100)
committerMark Andrews <marka@isc.org>
Mon, 25 Nov 2019 23:39:45 +0000 (23:39 +0000)
lib/dns/dispatch.c

index 2e534d26c3bf819093784651a733292170f43b23..c70ee9fa2515155603293c506e086dba59f020ca 100644 (file)
@@ -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);