emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101645: Add debugging to the gnutls


From: Lars Magne Ingebrigtsen
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101645: Add debugging to the gnutls library, and finish handshaking when it's done.
Date: Mon, 27 Sep 2010 16:35:22 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101645
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Mon 2010-09-27 16:35:22 +0200
message:
  Add debugging to the gnutls library, and finish handshaking when it's done.
modified:
  lisp/ChangeLog
  lisp/net/gnutls.el
  src/ChangeLog
  src/gnutls.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-09-26 22:42:53 +0000
+++ b/lisp/ChangeLog    2010-09-27 14:35:22 +0000
@@ -1,3 +1,8 @@
+2010-09-27  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * net/gnutls.el (starttls-negotiate): Stop looping when we get a t
+       back.
+
 2010-09-26  Stefan Monnier  <address@hidden>
 
        * emacs-lisp/pcase.el (pcase-let*, pcase-let): plet -> pcase-let.

=== modified file 'lisp/net/gnutls.el'
--- a/lisp/net/gnutls.el        2010-09-26 15:30:44 +0000
+++ b/lisp/net/gnutls.el        2010-09-27 14:35:22 +0000
@@ -80,13 +80,11 @@
 
     (let ((ret 'gnutls-e-again)
           (n 25000))
-      (while (and (not (gnutls-error-fatalp ret))
+      (while (and (not (eq ret t))
+                 (not (gnutls-error-fatalp ret))
                   (> n 0))
         (setq n (1- n))
-        (gnutls-message-maybe
-         (setq ret (gnutls-handshake proc))
-         "handshake: %s")
-        ;(debug "handshake ret" ret (gnutls-error-string ret)))
+       (setq ret (gnutls-handshake proc))
         )
       (if (gnutls-errorp ret)
           (progn

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-09-27 11:53:44 +0000
+++ b/src/ChangeLog     2010-09-27 14:35:22 +0000
@@ -1,3 +1,7 @@
+2010-09-27  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * gnutls.c (gnutls_log_function): Added more debugging.
+
 2010-09-27  Kenichi Handa  <address@hidden>
 
        These changes are to remove restriction on the number of glyphs in

=== modified file 'src/gnutls.c'
--- a/src/gnutls.c      2010-09-26 06:06:28 +0000
+++ b/src/gnutls.c      2010-09-27 14:35:22 +0000
@@ -221,6 +221,10 @@
   return gnutls_make_error (GNUTLS_E_SUCCESS);
 }
 
+static void gnutls_log_function (int level, const char* string) {
+  message("debug: %s", string);
+}
+
 DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 6, 0,
        doc: /* Initializes client-mode GnuTLS for process PROC.
 Currently only client mode is supported.  Returns a success/failure
@@ -264,6 +268,9 @@
 
   state = XPROCESS (proc)->gnutls_state;
 
+  gnutls_global_set_log_level(4);
+  gnutls_global_set_log_function(gnutls_log_function);
+  
   /* always initialize globals.  */
   global_init = gnutls_emacs_global_init ();
   if (! NILP (Fgnutls_errorp (global_init)))
@@ -272,19 +279,13 @@
   /* deinit and free resources.  */
   if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC)
   {
-      message ("gnutls: deallocating certificates");
-
       if (EQ (type, Qgnutls_x509pki))
       {
-          message ("gnutls: deallocating x509 certificates");
-
           x509_cred = XPROCESS (proc)->x509_cred;
           gnutls_certificate_free_credentials (x509_cred);
       }
       else if (EQ (type, Qgnutls_anon))
       {
-          message ("gnutls: deallocating anon certificates");
-
           anon_cred = XPROCESS (proc)->anon_cred;
           gnutls_anon_free_client_credentials (anon_cred);
       }
@@ -296,28 +297,20 @@
 
       if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
       {
-          message ("gnutls: deinitializing");
-
           Fgnutls_deinit (proc);
       }
   }
 
   GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY;
 
-  message ("gnutls: allocating credentials");
-
   if (EQ (type, Qgnutls_x509pki))
   {
-      message ("gnutls: allocating x509 credentials");
-
       x509_cred = XPROCESS (proc)->x509_cred;
       if (gnutls_certificate_allocate_credentials (&x509_cred) < 0)
         memory_full ();
   }
   else if (EQ (type, Qgnutls_anon))
   {
-      message ("gnutls: allocating anon credentials");
-
       anon_cred = XPROCESS (proc)->anon_cred;
       if (gnutls_anon_allocate_client_credentials (&anon_cred) < 0)
         memory_full ();
@@ -333,8 +326,6 @@
 
   GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC;
 
-  message ("gnutls: setting the trustfile");
-
   if (EQ (type, Qgnutls_x509pki))
   {
       if (STRINGP (trustfile))
@@ -346,12 +337,8 @@
 
           if (ret < GNUTLS_E_SUCCESS)
             return gnutls_make_error (ret);
-
-          message ("gnutls: processed %d CA certificates", ret);
       }
 
-      message ("gnutls: setting the keyfile");
-
       if (STRINGP (keyfile))
       {
           ret = gnutls_certificate_set_x509_crl_file
@@ -361,15 +348,11 @@
 
           if (ret < GNUTLS_E_SUCCESS)
             return gnutls_make_error (ret);
-
-          message ("gnutls: processed %d CRL(s)", ret);
       }
   }
 
   GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES;
 
-  message ("gnutls: gnutls_init");
-
   ret = gnutls_init (&state, GNUTLS_CLIENT);
 
   if (ret < GNUTLS_E_SUCCESS)
@@ -379,8 +362,6 @@
 
   GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT;
 
-  message ("gnutls: setting the priority string");
-
   ret = gnutls_priority_set_direct(state,
                                    (char*) SDATA (priority_string),
                                    NULL);
@@ -490,15 +471,14 @@
     GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_TRANSPORT_POINTERS_SET;
   }
 
-  message ("gnutls: handshake: handshaking");
   ret = gnutls_handshake (state);
-
   GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_HANDSHAKE_TRIED;
 
-  if (GNUTLS_E_SUCCESS == ret)
+  if (GNUTLS_E_SUCCESS == ret || ret == 0)
   {
     /* here we're finally done.  */
     GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_READY;
+    return Qt;
   }
 
   return gnutls_make_error (ret);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]