--- scheduler/client.c.orig	2022-05-26 08:17:21.000000000 +0200
+++ scheduler/client.c	2023-06-22 12:47:25.329404393 +0200
@@ -193,13 +193,10 @@ cupsdAcceptClient(cupsd_listener_t *lis)
    /*
     * Can't have an unresolved IP address with double-lookups enabled...
     */
-
-    httpClose(con->http);
-
     cupsdLogClient(con, CUPSD_LOG_WARN,
-                    "Name lookup failed - connection from %s closed!",
+                    "Name lookup failed - closing connection from %s!",
                     httpGetHostname(con->http, NULL, 0));
-
+    httpClose(con->http);
     free(con);
     return;
   }
@@ -234,12 +231,10 @@ cupsdAcceptClient(cupsd_listener_t *lis)
       * Can't have a hostname that doesn't resolve to the same IP address
       * with double-lookups enabled...
       */
-
-      httpClose(con->http);
-
       cupsdLogClient(con, CUPSD_LOG_WARN,
-                      "IP lookup failed - connection from %s closed!",
+                      "IP lookup failed - closing connection from %s!",
                       httpGetHostname(con->http, NULL, 0));
+      httpClose(con->http);
       free(con);
       return;
     }
@@ -256,11 +251,10 @@ cupsdAcceptClient(cupsd_listener_t *lis)
 
   if (!hosts_access(&wrap_req))
   {
-    httpClose(con->http);
-
     cupsdLogClient(con, CUPSD_LOG_WARN,
                     "Connection from %s refused by /etc/hosts.allow and "
 		    "/etc/hosts.deny rules.", httpGetHostname(con->http, NULL, 0));
+    httpClose(con->http);
     free(con);
     return;
   }
