diff options
| author | Lars Ingebrigtsen | 2016-03-03 05:14:48 +0000 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-03-03 05:14:55 +0000 |
| commit | 0c5c04d58e4efc04905a3f42e984d5f24c554a34 (patch) | |
| tree | 0608eda84b96019257d13f46b77f2b3d4cb65abb /src/process.c | |
| parent | 227ab51db6517bda1a557391bebaa7882b51963e (diff) | |
| download | emacs-0c5c04d58e4efc04905a3f42e984d5f24c554a34.tar.gz emacs-0c5c04d58e4efc04905a3f42e984d5f24c554a34.zip | |
Ensure TLS negotiation progress
* src/gnutls.h (GNUTLS_EMACS_HANDSHAKES_LIMIT): Increase the
number of retries so that we try for about a minute.
* src/process.c (wait_reading_process_output): Ensure progress
for DNS resolution and TLS negotiation.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/process.c b/src/process.c index 85a4885bbf4..4359f681b45 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -120,6 +120,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 120 | #endif | 120 | #endif |
| 121 | #endif | 121 | #endif |
| 122 | 122 | ||
| 123 | #if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS | ||
| 124 | /* This is 0.1s in nanoseconds. */ | ||
| 125 | #define ASYNC_RETRY_NSEC 100000000 | ||
| 126 | #endif | ||
| 127 | |||
| 123 | #ifdef WINDOWSNT | 128 | #ifdef WINDOWSNT |
| 124 | extern int sys_select (int, fd_set *, fd_set *, fd_set *, | 129 | extern int sys_select (int, fd_set *, fd_set *, fd_set *, |
| 125 | struct timespec *, void *); | 130 | struct timespec *, void *); |
| @@ -4870,6 +4875,9 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4870 | struct timespec got_output_end_time = invalid_timespec (); | 4875 | struct timespec got_output_end_time = invalid_timespec (); |
| 4871 | enum { MINIMUM = -1, TIMEOUT, INFINITY } wait; | 4876 | enum { MINIMUM = -1, TIMEOUT, INFINITY } wait; |
| 4872 | int got_some_output = -1; | 4877 | int got_some_output = -1; |
| 4878 | #if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS | ||
| 4879 | bool retry_for_async; | ||
| 4880 | #endif | ||
| 4873 | ptrdiff_t count = SPECPDL_INDEX (); | 4881 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4874 | 4882 | ||
| 4875 | /* Close to the current time if known, an invalid timespec otherwise. */ | 4883 | /* Close to the current time if known, an invalid timespec otherwise. */ |
| @@ -4922,6 +4930,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4922 | Lisp_Object process_list_head, aproc; | 4930 | Lisp_Object process_list_head, aproc; |
| 4923 | struct Lisp_Process *p; | 4931 | struct Lisp_Process *p; |
| 4924 | 4932 | ||
| 4933 | retry_for_async = false; | ||
| 4925 | FOR_EACH_PROCESS(process_list_head, aproc) | 4934 | FOR_EACH_PROCESS(process_list_head, aproc) |
| 4926 | { | 4935 | { |
| 4927 | p = XPROCESS (aproc); | 4936 | p = XPROCESS (aproc); |
| @@ -4935,6 +4944,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4935 | Lisp_Object ip_addresses = check_for_dns (aproc); | 4944 | Lisp_Object ip_addresses = check_for_dns (aproc); |
| 4936 | if (!NILP (ip_addresses) && !EQ (ip_addresses, Qt)) | 4945 | if (!NILP (ip_addresses) && !EQ (ip_addresses, Qt)) |
| 4937 | connect_network_socket (aproc, ip_addresses); | 4946 | connect_network_socket (aproc, ip_addresses); |
| 4947 | else | ||
| 4948 | retry_for_async = true; | ||
| 4938 | } | 4949 | } |
| 4939 | #endif | 4950 | #endif |
| 4940 | #ifdef HAVE_GNUTLS | 4951 | #ifdef HAVE_GNUTLS |
| @@ -4950,12 +4961,16 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4950 | gnutls_verify_boot (aproc, Qnil); | 4961 | gnutls_verify_boot (aproc, Qnil); |
| 4951 | finish_after_tls_connection (aproc); | 4962 | finish_after_tls_connection (aproc); |
| 4952 | } | 4963 | } |
| 4953 | else if (p->gnutls_handshakes_tried | 4964 | else |
| 4954 | > GNUTLS_EMACS_HANDSHAKES_LIMIT) | ||
| 4955 | { | 4965 | { |
| 4956 | deactivate_process (aproc); | 4966 | retry_for_async = true; |
| 4957 | pset_status (p, list2 (Qfailed, | 4967 | if (p->gnutls_handshakes_tried |
| 4958 | build_string ("TLS negotiation failed"))); | 4968 | > GNUTLS_EMACS_HANDSHAKES_LIMIT) |
| 4969 | { | ||
| 4970 | deactivate_process (aproc); | ||
| 4971 | pset_status (p, list2 (Qfailed, | ||
| 4972 | build_string ("TLS negotiation failed"))); | ||
| 4973 | } | ||
| 4959 | } | 4974 | } |
| 4960 | } | 4975 | } |
| 4961 | #endif | 4976 | #endif |
| @@ -5222,6 +5237,15 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 5222 | if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) | 5237 | if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) |
| 5223 | now = invalid_timespec (); | 5238 | now = invalid_timespec (); |
| 5224 | 5239 | ||
| 5240 | #if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS | ||
| 5241 | if (retry_for_async | ||
| 5242 | && (timeout.tv_sec > 0 || timeout.tv_nsec > ASYNC_RETRY_NSEC)) | ||
| 5243 | { | ||
| 5244 | timeout.tv_sec = 0; | ||
| 5245 | timeout.tv_nsec = ASYNC_RETRY_NSEC; | ||
| 5246 | } | ||
| 5247 | #endif | ||
| 5248 | |||
| 5225 | #if defined (HAVE_NS) | 5249 | #if defined (HAVE_NS) |
| 5226 | nfds = ns_select | 5250 | nfds = ns_select |
| 5227 | #elif defined (HAVE_GLIB) | 5251 | #elif defined (HAVE_GLIB) |