emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d5f270f: Return the correct error values from gnutl


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master d5f270f: Return the correct error values from gnutls.c
Date: Sun, 28 Feb 2016 03:34:12 +0000

branch: master
commit d5f270f2965f3c52963e2bf0057756e350d771d1
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Return the correct error values from gnutls.c
    
    * src/gnutls.c (emacs_gnutls_read): Set errno to the value
    expected by process.c.
    (gnutls_try_handshake): Set gnutls_p to true earlier to avoid
    possible race condition with the process.c socket polling
    functions.
---
 src/gnutls.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/gnutls.c b/src/gnutls.c
index d1b34c5..988c010 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -403,6 +403,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
   gnutls_session_t state = proc->gnutls_state;
   int ret;
 
+  if (proc->is_non_blocking_client)
+    proc->gnutls_p = true;
+
   do
     {
       ret = gnutls_handshake (state);
@@ -414,9 +417,6 @@ gnutls_try_handshake (struct Lisp_Process *proc)
 
   proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
 
-  if (proc->is_non_blocking_client)
-    proc->gnutls_p = true;
-
   if (ret == GNUTLS_E_SUCCESS)
     {
       /* Here we're finally done.  */
@@ -541,7 +541,10 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, 
ptrdiff_t nbyte)
   gnutls_session_t state = proc->gnutls_state;
 
   if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
-    return -1;
+    {
+      errno = EAGAIN;
+      return -1;
+    }
 
   rtnval = gnutls_record_recv (state, buf, nbyte);
   if (rtnval >= 0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]