From: Ted Zlatanov Date: Tue, 5 Nov 2013 02:29:03 +0000 (-0500) Subject: Several GnuTLS fixes for log level and initialization. X-Git-Url: https://git.hcoop.net/bpt/emacs.git/commitdiff_plain/194b4d9f7da7d539173b03d8a0ad434a86f6e124 Several GnuTLS fixes for log level and initialization. * gnutls.c (emacs_gnutls_handle_error): Adjust log level for EAGAIN. (Fgnutls_boot): Set process gnutls_p later, after initialization. * process.c (wait_reading_process_output, read_process_output) (send_process): Check gnutls_state is not NULL. --- diff --git a/src/ChangeLog b/src/ChangeLog index 5f919b8516..d0bdc6bee9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2013-11-05 Teodor Zlatanov + + * process.c (wait_reading_process_output, read_process_output) + (send_process): Check gnutls_state is not NULL. + + * gnutls.c (emacs_gnutls_handle_error): Adjust log level for EAGAIN. + (Fgnutls_boot): Set process gnutls_p later, after initialization. + 2013-11-04 Jan Djärv * nsterm.m (init, run, stop:): New methods in EmacsApp for diff --git a/src/gnutls.c b/src/gnutls.c index 0ee3fcae4a..5241c91f9c 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -488,8 +488,20 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err) else { ret = 1; - GNUTLS_LOG2 (1, max_log_level, "non-fatal error:", str); - /* TODO: EAGAIN AKA Qgnutls_e_again should be level 2. */ + + switch (err) + { + case GNUTLS_E_AGAIN: + GNUTLS_LOG2 (3, + max_log_level, + "retry:", + str); + default: + GNUTLS_LOG2 (1, + max_log_level, + "non-fatal error:", + str); + } } if (err == GNUTLS_E_WARNING_ALERT_RECEIVED @@ -810,7 +822,6 @@ one trustfile (usually a CA bundle). */) c_hostname = SSDATA (hostname); state = XPROCESS (proc)->gnutls_state; - XPROCESS (proc)->gnutls_p = 1; if (TYPE_RANGED_INTEGERP (int, loglevel)) { @@ -833,7 +844,6 @@ one trustfile (usually a CA bundle). */) emacs_gnutls_deinit (proc); /* Mark PROC as a GnuTLS process. */ - XPROCESS (proc)->gnutls_p = 1; XPROCESS (proc)->gnutls_state = NULL; XPROCESS (proc)->gnutls_x509_cred = NULL; XPROCESS (proc)->gnutls_anon_cred = NULL; @@ -1093,6 +1103,9 @@ one trustfile (usually a CA bundle). */) fn_gnutls_x509_crt_deinit (gnutls_verify_cert); } + // Only set this flag if the whole initialization succeeded. + XPROCESS (proc)->gnutls_p = 1; + return gnutls_make_error (ret); } diff --git a/src/process.c b/src/process.c index f6aa576e8b..ec4cda77e1 100644 --- a/src/process.c +++ b/src/process.c @@ -4609,7 +4609,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, { struct Lisp_Process *p = XPROCESS (chan_process[channel]); - if (p && p->gnutls_p && p->infd + if (p && p->gnutls_p && p->gnutls_state && p->infd && ((emacs_gnutls_record_check_pending (p->gnutls_state)) > 0)) @@ -4623,6 +4623,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, { /* Check this specific channel. */ if (wait_proc->gnutls_p /* Check for valid process. */ + && p->gnutls_state /* Do we have pending data? */ && ((emacs_gnutls_record_check_pending (wait_proc->gnutls_state)) @@ -5004,7 +5005,7 @@ read_process_output (Lisp_Object proc, register int channel) proc_buffered_char[channel] = -1; } #ifdef HAVE_GNUTLS - if (p->gnutls_p) + if (p->gnutls_p && p->gnutls_state) nbytes = emacs_gnutls_read (p, chars + carryover + buffered, readmax - buffered); else @@ -5498,7 +5499,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len, #endif { #ifdef HAVE_GNUTLS - if (p->gnutls_p) + if (p->gnutls_p && p->gnutls_state) written = emacs_gnutls_write (p, cur_buf, cur_len); else #endif