emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] feature/async-dns c85e7d4 1/2: Only do async DNS if reques


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] feature/async-dns c85e7d4 1/2: Only do async DNS if requested with :nowait 'dns
Date: Fri, 05 Feb 2016 03:03:40 +0000

branch: feature/async-dns
commit c85e7d4c8c899c01d6b4a393512bab295ef635c1
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Only do async DNS if requested with :nowait 'dns
    
    * doc/lispref/processes.texi (Network Processes): Mention the
    dns value of :nowait.
    
    * src/process.c (Fmake_network_process): Only do async DNS if
    :nowait is `dns'.
---
 doc/lispref/processes.texi |   10 ++++++++--
 lisp/net/network-stream.el |    8 ++++++--
 src/process.c              |   20 +++++++++++++-------
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index ccff138..a1c8755 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -2409,8 +2409,8 @@ as it may depend on implementation defined constants, 
data sizes, and
 data structure alignment.
 @end itemize
 
address@hidden :nowait @var{bool}
-If @var{bool} is address@hidden for a stream connection, return
address@hidden :nowait @var{nowait}
+If @var{nowait} is address@hidden for a stream connection, return
 without waiting for the connection to complete.  When the connection
 succeeds or fails, Emacs will call the sentinel function, with a
 second argument matching @code{"open"} (if successful) or
@@ -2418,6 +2418,12 @@ second argument matching @code{"open"} (if successful) or
 @code{make-network-process} does not return until the connection
 has succeeded or failed.
 
+If @var{nowait} is @code{dns}, also do the @acronym{DNS} lookup
+asynchronously, if supported.  In that case, the process is returned
+before a connection has been made, and the client should not try
+communicating with the process until it has changed status to
address@hidden"connected"}.
+
 @item :tls-parameters
 When opening a TLS connection, this should be where the first element
 is the TLS type (which should either be @code{gnutls-x509pki} or
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index 4925805..6767446 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -136,8 +136,12 @@ non-nil, is used warn the user if the connection isn't 
encrypted.
 :nogreeting is a boolean that can be used to inhibit waiting for
 a greeting from the server.
 
-:nowait is a boolean that says the connection should be made
-asynchronously, if possible.
+:nowait, if non-nil, says the connection should be made
+asynchronously, if possible.  If it is `dns', also do the DNS
+lookup asynchronously, if supported.  In that case, the process
+is returned before a connection has been made, and the client
+should not try communicating with the process until it has
+changed status to \"connected\".
 
 :tls-parameters is a list that should be supplied if you're
 opening a TLS connection.  The first element is the TLS
diff --git a/src/process.c b/src/process.c
index b232e33..86ca3f3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3421,11 +3421,16 @@ system used for both reading and writing for this 
process.  If CODING
 is a cons (DECODING . ENCODING), DECODING is used for reading, and
 ENCODING is used for writing.
 
-:nowait BOOL -- If BOOL is non-nil for a stream type client process,
-return without waiting for the connection to complete; instead, the
-sentinel function will be called with second arg matching "open" (if
-successful) or "failed" when the connect completes.  Default is to use
-a blocking connect (i.e. wait) for stream type connections.
+:nowait NOWAIT -- If NOWAIT is non-nil for a stream type client
+process, return without waiting for the connection to complete;
+instead, the sentinel function will be called with second arg matching
+"open" (if successful) or "failed" when the connect completes.
+Default is to use a blocking connect (i.e. wait) for stream type
+connections.  If NOWAIT is `dns', also do the DNS lookup
+asynchronously, if supported.  In that case, the process is returned
+before a connection has been made, and the client should not try
+communicating with the process until it has changed status to
+"connected".
 
 :noquery BOOL -- Query the user unless BOOL is non-nil, and process is
 running when Emacs is exited.
@@ -3688,7 +3693,7 @@ usage: (make-network-process &rest ARGS)  */)
 #endif
 
 #ifdef HAVE_GETADDRINFO_A
-  if (!NILP (Fplist_get (contact, QCnowait)) &&
+  if (EQ (Fplist_get (contact, QCnowait), Qdns) &&
       !NILP (host))
     {
       int ret;
@@ -4603,7 +4608,7 @@ check_for_dns (Lisp_Object proc)
     return Qnil;
 
   /* This process should not already be connected (or killed). */
-  if (p->infd != 0)
+  if (!EQ (p->status, Qconnect))
     return Qnil;
 
   ret = gai_error (p->dns_requests[0]);
@@ -7752,6 +7757,7 @@ syms_of_process (void)
   DEFSYM (QCcoding, ":coding");
   DEFSYM (QCserver, ":server");
   DEFSYM (QCnowait, ":nowait");
+  DEFSYM (Qdns, "dns");
   DEFSYM (QCsentinel, ":sentinel");
   DEFSYM (QCtls_parameters, ":tls-parameters");
   DEFSYM (QClog, ":log");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]