summaryrefslogtreecommitdiff
path: root/lisp/url
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2016-01-31 01:34:45 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2016-01-31 01:34:45 +0100
commit0f47153b97ae31b82366a857ec2f937c1580b637 (patch)
treea5e3bbc672c6d3f0ddcf11ae8c648eafa1a847e8 /lisp/url
parentcc45809152ab596deb2115369116e573d43c219a (diff)
downloademacs-0f47153b97ae31b82366a857ec2f937c1580b637.tar.gz
Implement asynchronous GnuTLS connections
* doc/misc/emacs-gnutls.texi (Help For Developers): Mention the nowait parameter. * lisp/net/gnutls.el (open-gnutls-stream): Allow asynchronous connections with the new nowait parameter. * lisp/net/network-stream.el (network-stream-open-tls): Pass on :nowait to open-gnutls-stream. * lisp/url/url-http.el (url-http): Don't overwrite the sentinel created by open-gnutls-stream. * src/gnutls.c (Fgnutls_mark_process): New function. * src/process.c (send_process): Don't write to GnuTLS sockets that haven't been initialised yed. * src/process.h: New slot gnutls_wait_p.
Diffstat (limited to 'lisp/url')
-rw-r--r--lisp/url/url-http.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 222dbc64d68..43b2862e0ea 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -1277,7 +1277,17 @@ The return value of this function is the retrieval buffer."
(pcase (process-status connection)
(`connect
;; Asynchronous connection
- (set-process-sentinel connection 'url-http-async-sentinel))
+ (if (not (process-sentinel connection))
+ (set-process-sentinel connection 'url-http-async-sentinel)
+ ;; If we already have a sentinel on this process (for
+ ;; instance on TLS connections), then chain them
+ ;; together.
+ (let ((old (process-sentinel connection)))
+ (set-process-sentinel
+ connection
+ `(lambda (proc why)
+ (funcall ',old proc why)
+ (url-http-async-sentinel proc why))))))
(`failed
;; Asynchronous connection failed
(error "Could not create connection to %s:%d" host port))