X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4628bef1eea0f60e846fe6b6591725aa92952de9..41d579ce4a2a86428f200788df4b15b936aa5076:/src/gnutls.c diff --git a/src/gnutls.c b/src/gnutls.c index 0913e1a3d2..3a461891e2 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -1,5 +1,5 @@ /* GnuTLS glue for GNU Emacs. - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -77,8 +77,15 @@ emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, register int rtnval, 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; +#endif +#ifdef EAGAIN + errno = EAGAIN; +#endif return -1; + } bytes_written = 0; @@ -86,9 +93,9 @@ emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, { rtnval = gnutls_write (state, buf, nbyte); - if (rtnval == -1) + if (rtnval < 0) { - if (errno == EINTR) + if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED) continue; else return (bytes_written ? bytes_written : -1); @@ -98,7 +105,6 @@ emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, nbyte -= rtnval; bytes_written += rtnval; } - fsync (STDOUT_FILENO); return (bytes_written); } @@ -119,8 +125,13 @@ emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf, rtnval = gnutls_read (state, buf, nbyte); if (rtnval >= 0) return rtnval; - else - return 0; + else { + if (rtnval == GNUTLS_E_AGAIN || + rtnval == GNUTLS_E_INTERRUPTED) + return -1; + else + return 0; + } } /* convert an integer error to a Lisp_Object; it will be either a @@ -437,7 +448,7 @@ one trustfile (usually a CA bundle). */) (x509_cred, SDATA (trustfile), file_format); - + if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); } @@ -459,7 +470,7 @@ one trustfile (usually a CA bundle). */) (x509_cred, SDATA (keyfile), file_format); - + if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); } @@ -486,7 +497,7 @@ one trustfile (usually a CA bundle). */) if (STRINGP (priority_string)) { - priority_string_ptr = (char*) SDATA (priority_string); + priority_string_ptr = SSDATA (priority_string); GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:", priority_string_ptr); } @@ -495,7 +506,7 @@ one trustfile (usually a CA bundle). */) GNUTLS_LOG2 (1, max_log_level, "using default priority string:", priority_string_ptr); } - + GNUTLS_LOG (1, max_log_level, "setting the priority string"); ret = gnutls_priority_set_direct (state, @@ -578,19 +589,19 @@ syms_of_gnutls (void) Qgnutls_x509pki = intern_c_string ("gnutls-x509pki"); staticpro (&Qgnutls_x509pki); - Qgnutls_bootprop_priority = intern_c_string ("priority"); + Qgnutls_bootprop_priority = intern_c_string (":priority"); staticpro (&Qgnutls_bootprop_priority); - Qgnutls_bootprop_trustfiles = intern_c_string ("trustfiles"); + Qgnutls_bootprop_trustfiles = intern_c_string (":trustfiles"); staticpro (&Qgnutls_bootprop_trustfiles); - Qgnutls_bootprop_keyfiles = intern_c_string ("keyfiles"); + Qgnutls_bootprop_keyfiles = intern_c_string (":keyfiles"); staticpro (&Qgnutls_bootprop_keyfiles); - Qgnutls_bootprop_callbacks = intern_c_string ("callbacks"); + Qgnutls_bootprop_callbacks = intern_c_string (":callbacks"); staticpro (&Qgnutls_bootprop_callbacks); - Qgnutls_bootprop_loglevel = intern_c_string ("loglevel"); + Qgnutls_bootprop_loglevel = intern_c_string (":loglevel"); staticpro (&Qgnutls_bootprop_loglevel); Qgnutls_e_interrupted = intern_c_string ("gnutls-e-interrupted");