aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-01-31 02:32:21 +0100
committerLars Ingebrigtsen2016-01-31 02:32:21 +0100
commitcecf6c9ac58ecd9ea251241a6b8a18e0e01dbc2a (patch)
tree3aeb6ebaa3f1418f48a99502107f1dae2703dd11 /src
parent1f71df7aacf15dbf242c74a4b7a7ac8fe0984a3c (diff)
downloademacs-cecf6c9ac58ecd9ea251241a6b8a18e0e01dbc2a.tar.gz
emacs-cecf6c9ac58ecd9ea251241a6b8a18e0e01dbc2a.zip
Rework the mechanisms for async GnuTLS connections
* lisp/net/gnutls.el (open-gnutls-stream): Compute the gnutls-boot parameters and pass them to the process object. (gnutls-negotiate): New parameter :return-keywords that won't connect to anything, just compute the keywords. * lisp/url/url-http.el (url-http): Revert async TLS sentinel hack, which is no longer necessary. * src/gnutls.c (Fgnutls_asynchronous_parameters): Rename from gnutls-mark-process. * src/process.c (connect_network_socket): If we're connecting to an asynchronous TLS socket, complete the GnuTLS boot sequence here. * src/process.h: New parameter gnutls_async_parameters.
Diffstat (limited to 'src')
-rw-r--r--src/gnutls.c13
-rw-r--r--src/process.c13
-rw-r--r--src/process.h2
3 files changed, 21 insertions, 7 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index d11b11c7c54..06459fb3ccd 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -686,13 +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, 689DEFUN ("gnutls-asynchronous-parameters", Fgnutls_asynchronous_parameters,
690 doc: /* Mark this process as being a pre-init GnuTLS process. */) 690 Sgnutls_asynchronous_parameters, 2, 2, 0,
691 (Lisp_Object proc, Lisp_Object state) 691 doc: /* Mark this process as being a pre-init GnuTLS process.
692The second parameter is the list of parameters to feed to gnutls-boot
693to finish setting up the connection. */)
694 (Lisp_Object proc, Lisp_Object params)
692{ 695{
693 CHECK_PROCESS (proc); 696 CHECK_PROCESS (proc);
694 697
695 XPROCESS (proc)->gnutls_wait_p = !NILP (state); 698 XPROCESS (proc)->gnutls_async_parameters = params;
696 return Qnil; 699 return Qnil;
697} 700}
698 701
@@ -1703,7 +1706,7 @@ syms_of_gnutls (void)
1703 make_number (GNUTLS_E_APPLICATION_ERROR_MIN)); 1706 make_number (GNUTLS_E_APPLICATION_ERROR_MIN));
1704 1707
1705 defsubr (&Sgnutls_get_initstage); 1708 defsubr (&Sgnutls_get_initstage);
1706 defsubr (&Sgnutls_mark_process); 1709 defsubr (&Sgnutls_asynchronous_parameters);
1707 defsubr (&Sgnutls_errorp); 1710 defsubr (&Sgnutls_errorp);
1708 defsubr (&Sgnutls_error_fatalp); 1711 defsubr (&Sgnutls_error_fatalp);
1709 defsubr (&Sgnutls_error_string); 1712 defsubr (&Sgnutls_error_string);
diff --git a/src/process.c b/src/process.c
index a30dd23077c..55264058340 100644
--- a/src/process.c
+++ b/src/process.c
@@ -715,6 +715,7 @@ make_process (Lisp_Object name)
715 715
716#ifdef HAVE_GNUTLS 716#ifdef HAVE_GNUTLS
717 p->gnutls_initstage = GNUTLS_STAGE_EMPTY; 717 p->gnutls_initstage = GNUTLS_STAGE_EMPTY;
718 p->gnutls_async_parameters = Qnil;
718#endif 719#endif
719 720
720 /* If name is already in use, modify it until it is unused. */ 721 /* If name is already in use, modify it until it is unused. */
@@ -3305,6 +3306,14 @@ void connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
3305 max_process_desc = inch; 3306 max_process_desc = inch;
3306 3307
3307 set_network_socket_coding_system (proc); 3308 set_network_socket_coding_system (proc);
3309
3310#ifdef HAVE_GNUTLS
3311 if (!NILP (p->gnutls_async_parameters) && p->is_non_blocking_client) {
3312 Fgnutls_boot (proc, Fcar (p->gnutls_async_parameters),
3313 Fcdr (p->gnutls_async_parameters));
3314 p->gnutls_async_parameters = Qnil;
3315 }
3316#endif
3308} 3317}
3309 3318
3310 3319
@@ -5817,7 +5826,9 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5817 error ("Output file descriptor of %s is closed", SDATA (p->name)); 5826 error ("Output file descriptor of %s is closed", SDATA (p->name));
5818 5827
5819#ifdef HAVE_GNUTLS 5828#ifdef HAVE_GNUTLS
5820 if (p->gnutls_wait_p) 5829 /* The TLS connection hasn't been set up yet, so we can't write
5830 anything on the socket. */
5831 if (p->gnutls_async_parameters)
5821 return; 5832 return;
5822#endif 5833#endif
5823 5834
diff --git a/src/process.h b/src/process.h
index 8bd555b83bd..eb34f5f0411 100644
--- a/src/process.h
+++ b/src/process.h
@@ -191,8 +191,8 @@ struct Lisp_Process
191 unsigned int gnutls_extra_peer_verification; 191 unsigned int gnutls_extra_peer_verification;
192 int gnutls_log_level; 192 int gnutls_log_level;
193 int gnutls_handshakes_tried; 193 int gnutls_handshakes_tried;
194 Lisp_Object gnutls_async_parameters;
194 bool_bf gnutls_p : 1; 195 bool_bf gnutls_p : 1;
195 bool_bf gnutls_wait_p : 1;
196#endif 196#endif
197}; 197};
198 198