aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-01-31 01:34:45 +0100
committerLars Ingebrigtsen2016-01-31 01:34:45 +0100
commit0f47153b97ae31b82366a857ec2f937c1580b637 (patch)
treea5e3bbc672c6d3f0ddcf11ae8c648eafa1a847e8 /src
parentcc45809152ab596deb2115369116e573d43c219a (diff)
downloademacs-0f47153b97ae31b82366a857ec2f937c1580b637.tar.gz
emacs-0f47153b97ae31b82366a857ec2f937c1580b637.zip
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 'src')
-rw-r--r--src/gnutls.c11
-rw-r--r--src/process.c5
-rw-r--r--src/process.h1
3 files changed, 17 insertions, 0 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index 01a5983d3b0..d11b11c7c54 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -686,6 +686,16 @@ emacs_gnutls_deinit (Lisp_Object proc)
686 return Qt; 686 return Qt;
687} 687}
688 688
689DEFUN ("gnutls-mark-process", Fgnutls_mark_process, Sgnutls_mark_process, 2, 2, 0,
690 doc: /* Mark this process as being a pre-init GnuTLS process. */)
691 (Lisp_Object proc, Lisp_Object state)
692{
693 CHECK_PROCESS (proc);
694
695 XPROCESS (proc)->gnutls_wait_p = !NILP (state);
696 return Qnil;
697}
698
689DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0, 699DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0,
690 doc: /* Return the GnuTLS init stage of process PROC. 700 doc: /* Return the GnuTLS init stage of process PROC.
691See also `gnutls-boot'. */) 701See also `gnutls-boot'. */)
@@ -1693,6 +1703,7 @@ syms_of_gnutls (void)
1693 make_number (GNUTLS_E_APPLICATION_ERROR_MIN)); 1703 make_number (GNUTLS_E_APPLICATION_ERROR_MIN));
1694 1704
1695 defsubr (&Sgnutls_get_initstage); 1705 defsubr (&Sgnutls_get_initstage);
1706 defsubr (&Sgnutls_mark_process);
1696 defsubr (&Sgnutls_errorp); 1707 defsubr (&Sgnutls_errorp);
1697 defsubr (&Sgnutls_error_fatalp); 1708 defsubr (&Sgnutls_error_fatalp);
1698 defsubr (&Sgnutls_error_string); 1709 defsubr (&Sgnutls_error_string);
diff --git a/src/process.c b/src/process.c
index 8cfa48db505..0fe45185361 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5806,6 +5806,11 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5806 if (p->outfd < 0) 5806 if (p->outfd < 0)
5807 error ("Output file descriptor of %s is closed", SDATA (p->name)); 5807 error ("Output file descriptor of %s is closed", SDATA (p->name));
5808 5808
5809#ifdef HAVE_GNUTLS
5810 if (p->gnutls_wait_p)
5811 return;
5812#endif
5813
5809 coding = proc_encode_coding_system[p->outfd]; 5814 coding = proc_encode_coding_system[p->outfd];
5810 Vlast_coding_system_used = CODING_ID_NAME (coding->id); 5815 Vlast_coding_system_used = CODING_ID_NAME (coding->id);
5811 5816
diff --git a/src/process.h b/src/process.h
index 990bbd55e3a..8bd555b83bd 100644
--- a/src/process.h
+++ b/src/process.h
@@ -192,6 +192,7 @@ struct Lisp_Process
192 int gnutls_log_level; 192 int gnutls_log_level;
193 int gnutls_handshakes_tried; 193 int gnutls_handshakes_tried;
194 bool_bf gnutls_p : 1; 194 bool_bf gnutls_p : 1;
195 bool_bf gnutls_wait_p : 1;
195#endif 196#endif
196}; 197};
197 198