aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-03-04 16:27:10 +0100
committerLars Ingebrigtsen2022-03-04 16:27:10 +0100
commitcdbc2f9d274a23bcf6cb03046b1e5b4bdcedafb1 (patch)
treeaef3f6a300ddbfe0a55364f0dc310e27a391dbdc /src
parent345c4c6532d3784eed5acbaea8a78ce3aad071e4 (diff)
downloademacs-cdbc2f9d274a23bcf6cb03046b1e5b4bdcedafb1.tar.gz
emacs-cdbc2f9d274a23bcf6cb03046b1e5b4bdcedafb1.zip
Add some sleeps to gnutls_try_handshake
* admin/merge-gnulib (GNULIB_MODULES): Add the nanosleep module. * m4/gnulib-comp.m4 (gl_EARLY): * lib/gnulib.mk.in: Automatic update. * m4/nanosleep.m4: * lib/nanosleep.c: New module. * nt/mingw-cfg.site (gl_cv_func_free_preserves_errno): * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_nanosleep): Omit nanosleep, since mingw has it. * src/gnutls.c (gnutls_try_handshake): Add some sleeping to the busy-wait loop so that we don't use 100% CPU here (bug#32452).
Diffstat (limited to 'src')
-rw-r--r--src/gnutls.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index 3ec38370679..09590ca005c 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -616,6 +616,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
616 gnutls_session_t state = proc->gnutls_state; 616 gnutls_session_t state = proc->gnutls_state;
617 int ret; 617 int ret;
618 bool non_blocking = proc->is_non_blocking_client; 618 bool non_blocking = proc->is_non_blocking_client;
619 /* Sleep for ten milliseconds when busy-looping in
620 gnutls_handshake. */
621 struct timespec delay = { 0, 1000 * 1000 * 10 };
619 622
620 if (proc->gnutls_complete_negotiation_p) 623 if (proc->gnutls_complete_negotiation_p)
621 non_blocking = false; 624 non_blocking = false;
@@ -630,6 +633,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
630 maybe_quit (); 633 maybe_quit ();
631 if (non_blocking && ret != GNUTLS_E_INTERRUPTED) 634 if (non_blocking && ret != GNUTLS_E_INTERRUPTED)
632 break; 635 break;
636 nanosleep (&delay, NULL);
633 } 637 }
634 638
635 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; 639 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;