aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTed Zlatanov2013-11-04 21:29:03 -0500
committerTed Zlatanov2013-11-04 21:29:03 -0500
commit194b4d9f7da7d539173b03d8a0ad434a86f6e124 (patch)
tree58e4bc5e422254ab7029f46c0402458bb3fc72a4 /src
parentb5d402d6bda921874bc6ad6a560b19b59ac62a29 (diff)
downloademacs-194b4d9f7da7d539173b03d8a0ad434a86f6e124.tar.gz
emacs-194b4d9f7da7d539173b03d8a0ad434a86f6e124.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/gnutls.c21
-rw-r--r--src/process.c7
3 files changed, 29 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5f919b8516d..d0bdc6bee94 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12013-11-05 Teodor Zlatanov <tzz@lifelogs.com>
2
3 * process.c (wait_reading_process_output, read_process_output)
4 (send_process): Check gnutls_state is not NULL.
5
6 * gnutls.c (emacs_gnutls_handle_error): Adjust log level for EAGAIN.
7 (Fgnutls_boot): Set process gnutls_p later, after initialization.
8
12013-11-04 Jan Djärv <jan.h.d@swipnet.se> 92013-11-04 Jan Djärv <jan.h.d@swipnet.se>
2 10
3 * nsterm.m (init, run, stop:): New methods in EmacsApp for 11 * nsterm.m (init, run, stop:): New methods in EmacsApp for
diff --git a/src/gnutls.c b/src/gnutls.c
index 0ee3fcae4a4..5241c91f9cb 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -488,8 +488,20 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err)
488 else 488 else
489 { 489 {
490 ret = 1; 490 ret = 1;
491 GNUTLS_LOG2 (1, max_log_level, "non-fatal error:", str); 491
492 /* TODO: EAGAIN AKA Qgnutls_e_again should be level 2. */ 492 switch (err)
493 {
494 case GNUTLS_E_AGAIN:
495 GNUTLS_LOG2 (3,
496 max_log_level,
497 "retry:",
498 str);
499 default:
500 GNUTLS_LOG2 (1,
501 max_log_level,
502 "non-fatal error:",
503 str);
504 }
493 } 505 }
494 506
495 if (err == GNUTLS_E_WARNING_ALERT_RECEIVED 507 if (err == GNUTLS_E_WARNING_ALERT_RECEIVED
@@ -810,7 +822,6 @@ one trustfile (usually a CA bundle). */)
810 c_hostname = SSDATA (hostname); 822 c_hostname = SSDATA (hostname);
811 823
812 state = XPROCESS (proc)->gnutls_state; 824 state = XPROCESS (proc)->gnutls_state;
813 XPROCESS (proc)->gnutls_p = 1;
814 825
815 if (TYPE_RANGED_INTEGERP (int, loglevel)) 826 if (TYPE_RANGED_INTEGERP (int, loglevel))
816 { 827 {
@@ -833,7 +844,6 @@ one trustfile (usually a CA bundle). */)
833 emacs_gnutls_deinit (proc); 844 emacs_gnutls_deinit (proc);
834 845
835 /* Mark PROC as a GnuTLS process. */ 846 /* Mark PROC as a GnuTLS process. */
836 XPROCESS (proc)->gnutls_p = 1;
837 XPROCESS (proc)->gnutls_state = NULL; 847 XPROCESS (proc)->gnutls_state = NULL;
838 XPROCESS (proc)->gnutls_x509_cred = NULL; 848 XPROCESS (proc)->gnutls_x509_cred = NULL;
839 XPROCESS (proc)->gnutls_anon_cred = NULL; 849 XPROCESS (proc)->gnutls_anon_cred = NULL;
@@ -1093,6 +1103,9 @@ one trustfile (usually a CA bundle). */)
1093 fn_gnutls_x509_crt_deinit (gnutls_verify_cert); 1103 fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
1094 } 1104 }
1095 1105
1106 // Only set this flag if the whole initialization succeeded.
1107 XPROCESS (proc)->gnutls_p = 1;
1108
1096 return gnutls_make_error (ret); 1109 return gnutls_make_error (ret);
1097} 1110}
1098 1111
diff --git a/src/process.c b/src/process.c
index f6aa576e8b7..ec4cda77e1c 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,
4609 { 4609 {
4610 struct Lisp_Process *p = 4610 struct Lisp_Process *p =
4611 XPROCESS (chan_process[channel]); 4611 XPROCESS (chan_process[channel]);
4612 if (p && p->gnutls_p && p->infd 4612 if (p && p->gnutls_p && p->gnutls_state && p->infd
4613 && ((emacs_gnutls_record_check_pending 4613 && ((emacs_gnutls_record_check_pending
4614 (p->gnutls_state)) 4614 (p->gnutls_state))
4615 > 0)) 4615 > 0))
@@ -4623,6 +4623,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4623 { 4623 {
4624 /* Check this specific channel. */ 4624 /* Check this specific channel. */
4625 if (wait_proc->gnutls_p /* Check for valid process. */ 4625 if (wait_proc->gnutls_p /* Check for valid process. */
4626 && p->gnutls_state
4626 /* Do we have pending data? */ 4627 /* Do we have pending data? */
4627 && ((emacs_gnutls_record_check_pending 4628 && ((emacs_gnutls_record_check_pending
4628 (wait_proc->gnutls_state)) 4629 (wait_proc->gnutls_state))
@@ -5004,7 +5005,7 @@ read_process_output (Lisp_Object proc, register int channel)
5004 proc_buffered_char[channel] = -1; 5005 proc_buffered_char[channel] = -1;
5005 } 5006 }
5006#ifdef HAVE_GNUTLS 5007#ifdef HAVE_GNUTLS
5007 if (p->gnutls_p) 5008 if (p->gnutls_p && p->gnutls_state)
5008 nbytes = emacs_gnutls_read (p, chars + carryover + buffered, 5009 nbytes = emacs_gnutls_read (p, chars + carryover + buffered,
5009 readmax - buffered); 5010 readmax - buffered);
5010 else 5011 else
@@ -5498,7 +5499,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5498#endif 5499#endif
5499 { 5500 {
5500#ifdef HAVE_GNUTLS 5501#ifdef HAVE_GNUTLS
5501 if (p->gnutls_p) 5502 if (p->gnutls_p && p->gnutls_state)
5502 written = emacs_gnutls_write (p, cur_buf, cur_len); 5503 written = emacs_gnutls_write (p, cur_buf, cur_len);
5503 else 5504 else
5504#endif 5505#endif