summaryrefslogtreecommitdiff
path: root/src/gnutls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnutls.c')
-rw-r--r--src/gnutls.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index a4eeb50bd74..99fc5c10e2b 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -345,15 +345,16 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte)
ptrdiff_t bytes_written;
gnutls_session_t state = proc->gnutls_state;
- if (proc->gnutls_initstage != GNUTLS_STAGE_READY) {
+ if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
+ {
#ifdef EWOULDBLOCK
- errno = EWOULDBLOCK;
+ errno = EWOULDBLOCK;
#endif
#ifdef EAGAIN
- errno = EAGAIN;
+ errno = EAGAIN;
#endif
- return 0;
- }
+ return 0;
+ }
bytes_written = 0;
@@ -363,10 +364,24 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte)
if (rtnval < 0)
{
- if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED)
+ if (rtnval == GNUTLS_E_INTERRUPTED)
continue;
else
- break;
+ {
+ /* If we get GNUTLS_E_AGAIN, then set errno
+ appropriately so that send_process retries the
+ correct way instead of erroring out. */
+ if (rtnval == GNUTLS_E_AGAIN)
+ {
+#ifdef EWOULDBLOCK
+ errno = EWOULDBLOCK;
+#endif
+#ifdef EAGAIN
+ errno = EAGAIN;
+#endif
+ }
+ break;
+ }
}
buf += rtnval;