Subject: bug#78920: 30.1; Process sentinel is not called when DNS lookup fails

From: Robert Pluim <[email-masked]>
Date: Mon, 30 Jun 2025 14:46:21 +0200

>>>>> On Mon, 30 Jun 2025 15:20:53 +0300, Eli Zaretskii <[email-masked]> said:

    >> From: Shawn Henson <[email-masked]>
    >> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
    >> Date: Sun, 29 Jun 2025 17:22:36 -0400
    >> 
    >> Robert Pluim <[email-masked]> writes:
    >> 
    >> > I wonder what Emacs does for ":nowait t" without async DNS, when the
    >> > connect fails. Iʼd expect it to call the sentinel with a "failed"
    >> > status.
    >> 
    >> Is there a trivial way to test this?

    Eli> Run the recipe on MS-Windows ;-)

    Eli> The result is that we signal an error:

    Eli>   Debugger entered--Lisp error: (error "thisisnotarealhostname/80 No such host is known. ")
    Eli>     make-network-process(:name "dns-fail-test" :buffer "dns-fail-test-buf" :host "thisisnotarealhostname" :service 80 :nowait t :sentinel #f(lambda (process event) [t] (print event)))
    Eli>     (let ((my-test-proc (make-network-process :name "dns-fail-test" :buffer "dns-fail-test-buf" :host "thisisnotarealhostname" :service 80 :nowait t :sentinel #'(lambda (process event) (print event))))) (message "process status: %s" (process-status my-test-proc)))
    Eli>     (progn (let ((my-test-proc (make-network-process :name "dns-fail-test" :buffer "dns-fail-test-buf" :host "thisisnotarealhostname" :service 80 :nowait t :sentinel #'(lambda (process event) (print event))))) (message "process status: %s" (process-status my-test-proc))))
    Eli>     eval((progn (let ((my-test-proc (make-network-process :name "dns-fail-test" :buffer "dns-fail-test-buf" :host "thisisnotarealhostname" :service 80 :nowait t :sentinel #'(lambda ... ...)))) (message "process status: %s" (process-status my-test-proc)))) t)

    Eli> and there's no process shown by list-processes.

Yes, in retrospect that makes sense as a behaviour. But we canʼt do
that with async DNS + :nowait t. Something like the following perhaps?
Although I think the sentinel still gets called when you delete the
leftover process, so probably more is needed.

Robert
-- 

diff --git a/src/process.c b/src/process.c
index e61ec425f7e..473d8294a88 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5172,6 +5172,7 @@ check_for_dns (Lisp_Object proc)
 			concat3 (build_string ("Name lookup of "),
 				 build_string (p->dns_request->ar_name),
 				 build_string (" failed")))));
+      exec_sentinel (proc, build_string ("Name lookup failed\n"));
     }