]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Accept overquota TCP connection on local thread if possible
authorOndřej Surý <ondrej@isc.org>
Sat, 8 Apr 2023 11:54:52 +0000 (13:54 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 12 Apr 2023 12:10:37 +0000 (14:10 +0200)
If the quota callback is called on a thread matching the socket, call
the TCP accept function directly instead of using isc_async_run() which
allocates-deallocates memory.

lib/isc/netmgr/tcp.c

index b5c0facdc2cbccf8ffb7a4fce07eba73f6f71099..670db30579475759f8775e5e85becf959f8d6f0a 100644 (file)
@@ -865,8 +865,15 @@ quota_accept_cb(isc_quota_t *quota, void *arg) {
         * This needs to be asynchronous, because the quota might have been
         * released by a different child socket.
         */
-       isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
-       isc_async_run(sock->worker->loop, tcpaccept_cb, sock);
+       if (sock->tid == isc_tid()) {
+               isc_result_t result = accept_connection(sock);
+               isc__nm_accept_connection_log(sock, result,
+                                             can_log_tcp_quota());
+               sock->pquota = NULL;
+       } else {
+               isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
+               isc_async_run(sock->worker->loop, tcpaccept_cb, sock);
+       }
 }
 
 static isc_result_t