aboutsummaryrefslogtreecommitdiffstats
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 d7bf0e8edb8..6b5cb47001b 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -345,15 +345,16 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte)
345 EMACS_INT bytes_written; 345 EMACS_INT bytes_written;
346 gnutls_session_t state = proc->gnutls_state; 346 gnutls_session_t state = proc->gnutls_state;
347 347
348 if (proc->gnutls_initstage != GNUTLS_STAGE_READY) { 348 if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
349 {
349#ifdef EWOULDBLOCK 350#ifdef EWOULDBLOCK
350 errno = EWOULDBLOCK; 351 errno = EWOULDBLOCK;
351#endif 352#endif
352#ifdef EAGAIN 353#ifdef EAGAIN
353 errno = EAGAIN; 354 errno = EAGAIN;
354#endif 355#endif
355 return 0; 356 return 0;
356 } 357 }
357 358
358 bytes_written = 0; 359 bytes_written = 0;
359 360
@@ -363,10 +364,24 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte)
363 364
364 if (rtnval < 0) 365 if (rtnval < 0)
365 { 366 {
366 if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED) 367 if (rtnval == GNUTLS_E_INTERRUPTED)
367 continue; 368 continue;
368 else 369 else
369 break; 370 {
371 /* If we get GNUTLS_E_AGAIN, then set errno
372 appropriately so that send_process retries the
373 correct way instead of erroring out. */
374 if (rtnval == GNUTLS_E_AGAIN)
375 {
376#ifdef EWOULDBLOCK
377 errno = EWOULDBLOCK;
378#endif
379#ifdef EAGAIN
380 errno = EAGAIN;
381#endif
382 }
383 break;
384 }
370 } 385 }
371 386
372 buf += rtnval; 387 buf += rtnval;