aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-28 14:03:50 +1030
committerLars Ingebrigtsen2016-02-28 14:04:04 +1030
commitd5f270f2965f3c52963e2bf0057756e350d771d1 (patch)
tree0fe5a3517e2c2808b029a009dd7d5721d8855490 /src
parentb829c9e15b244e12a98e5dc75c8009d55b60bfab (diff)
downloademacs-d5f270f2965f3c52963e2bf0057756e350d771d1.tar.gz
emacs-d5f270f2965f3c52963e2bf0057756e350d771d1.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/gnutls.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index d1b34c5bf7f..988c0104869 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -403,6 +403,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
403 gnutls_session_t state = proc->gnutls_state; 403 gnutls_session_t state = proc->gnutls_state;
404 int ret; 404 int ret;
405 405
406 if (proc->is_non_blocking_client)
407 proc->gnutls_p = true;
408
406 do 409 do
407 { 410 {
408 ret = gnutls_handshake (state); 411 ret = gnutls_handshake (state);
@@ -414,9 +417,6 @@ gnutls_try_handshake (struct Lisp_Process *proc)
414 417
415 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; 418 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
416 419
417 if (proc->is_non_blocking_client)
418 proc->gnutls_p = true;
419
420 if (ret == GNUTLS_E_SUCCESS) 420 if (ret == GNUTLS_E_SUCCESS)
421 { 421 {
422 /* Here we're finally done. */ 422 /* Here we're finally done. */
@@ -541,7 +541,10 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte)
541 gnutls_session_t state = proc->gnutls_state; 541 gnutls_session_t state = proc->gnutls_state;
542 542
543 if (proc->gnutls_initstage != GNUTLS_STAGE_READY) 543 if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
544 return -1; 544 {
545 errno = EAGAIN;
546 return -1;
547 }
545 548
546 rtnval = gnutls_record_recv (state, buf, nbyte); 549 rtnval = gnutls_record_recv (state, buf, nbyte);
547 if (rtnval >= 0) 550 if (rtnval >= 0)