[glib-networking/wip/verification] Remove all the debug



commit 47753cbaf9b18a750e8711ea717addc5a4330ed6
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Thu Jul 26 20:06:25 2018 -0500

    Remove all the debug

 tls/gnutls/gtlsconnection-gnutls.c | 128 -------------------------------------
 tls/tests/connection.c             |   3 -
 2 files changed, 131 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 57877e9..e2a4f27 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -259,35 +259,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GTlsConnectionGnutls, g_tls_connection_gnutls,
 
 static gint unique_interaction_id = 0;
 
-#include <glib/gprintf.h>
-static void
-GTLS_DEBUG (GTlsConnectionGnutls *gnutls,
-            const char           *format,
-            ...)
-{
-  char *new_format;
-  char *result;
-  va_list args;
-
-  va_start (args, format);
-
-  if (G_IS_TLS_SERVER_CONNECTION (gnutls))
-    new_format = g_strdup_printf ("SERVER: %s", format);
-  else if (G_IS_TLS_CLIENT_CONNECTION (gnutls))
-    new_format = g_strdup_printf ("CLIENT: %s", format);
-  else
-    g_assert_not_reached ();
-
-  g_vasprintf (&result, new_format, args);
-
-  //g_info (result);
-
-  va_end (args);
-
-  g_free (new_format);
-  g_free (result);
-}
-
 static void
 g_tls_connection_gnutls_init (GTlsConnectionGnutls *gnutls)
 {
@@ -884,33 +855,20 @@ claim_op (GTlsConnectionGnutls    *gnutls,
 
   if (op == G_TLS_CONNECTION_GNUTLS_OP_HANDSHAKE)
     {
-GTLS_DEBUG(gnutls, "Claimed handshake op!");
       priv->handshaking = TRUE;
       priv->need_handshake = FALSE;
     }
   if (op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_BOTH ||
       op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_READ)
-{
-GTLS_DEBUG(gnutls, "Claimed close read op!");
     priv->read_closing = TRUE;
-}
   if (op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_BOTH ||
       op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_WRITE)
-{
-GTLS_DEBUG(gnutls, "Claimed close write op!");
     priv->write_closing = TRUE;
-}
 
   if (op != G_TLS_CONNECTION_GNUTLS_OP_WRITE)
-{
-GTLS_DEBUG(gnutls, "Claimed non-write op, reading=true!");
     priv->reading = TRUE;
-}
   if (op != G_TLS_CONNECTION_GNUTLS_OP_READ)
-{
-GTLS_DEBUG(gnutls, "Claimed non-read op, writing=true!");
     priv->writing = TRUE;
-}
 
   g_mutex_unlock (&priv->op_mutex);
   return TRUE;
@@ -925,33 +883,18 @@ yield_op (GTlsConnectionGnutls   *gnutls,
   g_mutex_lock (&priv->op_mutex);
 
   if (op == G_TLS_CONNECTION_GNUTLS_OP_HANDSHAKE)
-{
-GTLS_DEBUG(gnutls, "Yielded handshake op!");
     priv->handshaking = FALSE;
-}
   if (op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_BOTH ||
       op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_READ)
-{
-GTLS_DEBUG(gnutls, "Yielded read close op!");
     priv->read_closing = FALSE;
-}
   if (op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_BOTH ||
       op == G_TLS_CONNECTION_GNUTLS_OP_CLOSE_WRITE)
-{
-GTLS_DEBUG(gnutls, "Yielded write close op!");
     priv->write_closing = FALSE;
-}
 
   if (op != G_TLS_CONNECTION_GNUTLS_OP_WRITE)
-{
-GTLS_DEBUG(gnutls, "Yielded non-write op, reading=false!");
     priv->reading = FALSE;
-}
   if (op != G_TLS_CONNECTION_GNUTLS_OP_READ)
-{
-GTLS_DEBUG(gnutls, "Yielded non-read op, writing=false!");
     priv->writing = FALSE;
-}
 
   g_cancellable_cancel (priv->waiting_for_op);
   g_mutex_unlock (&priv->op_mutex);
@@ -1055,7 +998,6 @@ end_gnutls_io (GTlsConnectionGnutls  *gnutls,
 
   if (my_error)
     {
-GTLS_DEBUG(gnutls, "%s: my_error code=%d (%s)", __FUNCTION__, my_error->code, my_error->message);
       if (!g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK) &&
           !g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT))
         G_TLS_CONNECTION_GNUTLS_GET_CLASS (gnutls)->failed (gnutls);
@@ -1133,7 +1075,6 @@ GTLS_DEBUG(gnutls, "%s: my_error code=%d (%s)", __FUNCTION__, my_error->code, my
     {
       *error = g_error_new (G_TLS_ERROR, G_TLS_ERROR_MISC, "%s: %s",
           err_prefix, gnutls_strerror (status));
-GTLS_DEBUG(gnutls, "%s: setting error %s %s (BAD!)", __FUNCTION__, err_prefix, gnutls_strerror (status));
     }
   return status;
 }
@@ -1236,14 +1177,9 @@ gnutls_source_sync (GTlsConnectionGnutlsSource *gnutls_source)
   GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
   gboolean io_waiting, op_waiting;
 
-GTLS_DEBUG(gnutls_source->gnutls, "%s: source=%p", __FUNCTION__, gnutls_source);
-
   /* Was the source destroyed earlier in this main context iteration? */
   if (g_source_is_destroyed ((GSource *)gnutls_source))
-{
-GTLS_DEBUG(gnutls_source->gnutls, "source=%p already destroyed!", gnutls_source);
     return;
-}
 
   g_mutex_lock (&priv->op_mutex);
   if (((gnutls_source->condition & G_IO_IN) && priv->reading) ||
@@ -1299,22 +1235,14 @@ gnutls_source_dispatch (GSource     *source,
   gboolean ret;
 
   if (G_IS_DATAGRAM_BASED (gnutls_source->base))
-{
-GTLS_DEBUG(gnutls_source->gnutls, "%s: source=%p the fuck?", __FUNCTION__, source);
     ret = (*datagram_based_func) (G_DATAGRAM_BASED (gnutls_source->base),
                                   gnutls_source->condition, user_data);
-}
   else
-{
-GTLS_DEBUG(gnutls_source->gnutls, "%s: source=%p calling pollable_func", __FUNCTION__, source);
     ret = (*pollable_func) (gnutls_source->base, user_data);
-}
 
   if (ret)
     gnutls_source_sync (gnutls_source);
 
-GTLS_DEBUG(gnutls_source->gnutls, "%s: source=%p ret=%d", __FUNCTION__, source, ret);
-
   return ret;
 }
 
@@ -1323,8 +1251,6 @@ gnutls_source_finalize (GSource *source)
 {
   GTlsConnectionGnutlsSource *gnutls_source = (GTlsConnectionGnutlsSource *)source;
 
-GTLS_DEBUG(gnutls_source->gnutls, "%s source=%p", __FUNCTION__, source);
-
   g_object_unref (gnutls_source->gnutls);
   g_source_unref (gnutls_source->child_source);
 }
@@ -1420,7 +1346,6 @@ g_tls_connection_gnutls_create_source (GTlsConnectionGnutls  *gnutls,
       source = g_source_new (&gnutls_tls_source_funcs,
                              sizeof (GTlsConnectionGnutlsSource));
     }
-GTLS_DEBUG(gnutls, "%s new gnutls_source=%p", __FUNCTION__, source);
   g_source_set_name (source, "GTlsConnectionGnutlsSource");
   gnutls_source = (GTlsConnectionGnutlsSource *)source;
   gnutls_source->gnutls = g_object_ref (gnutls);
@@ -1532,7 +1457,6 @@ set_gnutls_error (GTlsConnectionGnutls *gnutls,
                   GError               *error)
 {
   GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
-GTLS_DEBUG(gnutls, "%s: error=%s", __FUNCTION__, error->message);
   /* We set EINTR rather than EAGAIN for G_IO_ERROR_WOULD_BLOCK so
    * that GNUTLS_E_AGAIN only gets returned for gnutls-internal
    * reasons, not for actual socket EAGAINs (and we have access
@@ -1895,14 +1819,11 @@ accept_certificate_cb (gpointer user_data)
                                                              priv->peer_certificate_errors);
 
 // FIXME: It's already locked by verify_certificate_cb...
-GTLS_DEBUG(gnutls, "Locking verify_certificate_mutex in accept_certificate_cb");
   g_mutex_lock (&priv->verify_certificate_mutex);
-GTLS_DEBUG(gnutls, "Successfully locked verify_certificate_mutex in accept_certificate_cb");
   priv->peer_certificate_examined = TRUE;
 
   g_cond_signal (&priv->verify_certificate_condition);
   g_mutex_unlock (&priv->verify_certificate_mutex);
-GTLS_DEBUG(gnutls, "Unlocked verify_certificate_mutex in accept_certificate_cb");
 
   g_object_notify (G_OBJECT (gnutls), "peer-certificate");
   g_object_notify (G_OBJECT (gnutls), "peer-certificate-errors");
@@ -1932,16 +1853,13 @@ verify_certificate_cb (gnutls_session_t session)
   /* We'll block the handshake thread until the original thread has
    * decided whether to accept the certificate.
    */
-GTLS_DEBUG(gnutls, "Locking verify_certificate_mutex in verify_certificate_cb");
   g_mutex_lock (&priv->verify_certificate_mutex);
   while (!priv->peer_certificate_examined)
     g_cond_wait (&priv->verify_certificate_condition, &priv->verify_certificate_mutex);
   accepted = priv->peer_certificate_accepted;
   g_mutex_unlock (&priv->verify_certificate_mutex);
-GTLS_DEBUG(gnutls, "Unlocked verify_certificate_mutex in verify_certificate_cb");
 
   /* Return 0 for the handshake to continue, non-zero to terminate. */
-GTLS_DEBUG(gnutls, "%s: certificate is accepted? %d", __FUNCTION__, accepted);
   return !accepted;
 }
 
@@ -2068,12 +1986,10 @@ handshake_thread (GTask        *task,
 
   if (error)
     {
-GTLS_DEBUG(gnutls, "Error: %s", error->message);
       g_task_return_error (task, error);
     }
   else
     {
-GTLS_DEBUG(gnutls, "Handshake success!");
       priv->ever_handshaked = TRUE;
       g_task_return_boolean (task, TRUE);
     }
@@ -2098,11 +2014,7 @@ accept_peer_certificate (GTlsConnectionGnutls *gnutls,
           g_dtls_client_connection_get_validation_flags (G_DTLS_CLIENT_CONNECTION (gnutls));
 
       if ((peer_certificate_errors & validation_flags) == 0)
-{
-GTLS_DEBUG(gnutls, "%s peer_certificate_errors=%d validation_flags=%d errors&flags=%d (0 is good)",
-__FUNCTION__, peer_certificate_errors, validation_flags, peer_certificate_errors & validation_flags);
         accepted = TRUE;
-}
     }
 
   if (!accepted)
@@ -2127,7 +2039,6 @@ finish_handshake (GTlsConnectionGnutls  *gnutls,
                   GError               **error)
 {
   GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
-GTLS_DEBUG (gnutls, "%s", __FUNCTION__);
   g_assert (error != NULL);
 
 // FIXME FIXME FIXME: Is this safe to remove?
@@ -2157,7 +2068,6 @@ sync_handshake_thread_completed (GObject      *object,
   g_mutex_unlock (&priv->op_mutex);
 
   g_main_context_wakeup (priv->handshake_context);
-GTLS_DEBUG(gnutls, "WAKEUP! need_finish_handshake=TRUE");
 }
 
 static void
@@ -2168,13 +2078,10 @@ crank_sync_handshake_context (GTlsConnectionGnutls *gnutls,
 
   g_mutex_lock (&priv->op_mutex);
   priv->need_finish_handshake = FALSE;
-GTLS_DEBUG(gnutls, "%s: need_finish_handshake=FALSE", __FUNCTION__);
   while (!priv->need_finish_handshake && !g_cancellable_is_cancelled (cancellable))
     {
       g_mutex_unlock (&priv->op_mutex);
-GTLS_DEBUG(gnutls, "%s: STARTING MAIN CONTEXT=%p ITERATION because need_finish_handshake == FALSE", 
__FUNCTION__, priv->handshake_context);
       g_main_context_iteration (priv->handshake_context, TRUE);
-GTLS_DEBUG(gnutls, "%s: FINISHED MAIN CONTEXT=%p ITERATION", __FUNCTION__, priv->handshake_context);
       g_mutex_lock (&priv->op_mutex);
     }
   g_mutex_unlock (&priv->op_mutex);
@@ -2192,8 +2099,6 @@ g_tls_connection_gnutls_handshake (GTlsConnection   *conn,
   gint64 *timeout = NULL;
   GError *my_error = NULL;
 
-GTLS_DEBUG(gnutls, "%s: calling begin_handshake", __FUNCTION__);
-
   g_assert (priv->handshake_context == NULL);
   priv->handshake_context = g_main_context_new ();
 
@@ -2208,10 +2113,8 @@ GTLS_DEBUG(gnutls, "%s: calling begin_handshake", __FUNCTION__);
   *timeout = -1;  /* blocking */
   g_task_set_task_data (task, timeout, g_free);
 
-GTLS_DEBUG(gnutls, "%s: starting handshake thread and cranking the context", __FUNCTION__);
   g_task_run_in_thread (task, handshake_thread);
   crank_sync_handshake_context (gnutls, cancellable);
-GTLS_DEBUG(gnutls, "%s: finished cranking the handshake context", __FUNCTION__);
 
   g_main_context_pop_thread_default (priv->handshake_context);
 
@@ -2261,7 +2164,6 @@ handshake_thread_completed (GObject      *object,
     }
   else
     need_finish_handshake = FALSE;
-GTLS_DEBUG(gnutls, "%s: need_finish_handshake=FALSE", __FUNCTION__);
   g_mutex_unlock (&priv->op_mutex);
 
   if (need_finish_handshake)
@@ -2292,7 +2194,6 @@ async_handshake_thread (GTask        *task,
 
   g_mutex_lock (&priv->op_mutex);
   priv->need_finish_handshake = TRUE;
-GTLS_DEBUG(gnutls, "%s: need_finish_handshake=TRUE", __FUNCTION__);
   /* yield_op will clear handshaking too, but we don't want the
    * connection to be briefly "handshaking && need_finish_handshake"
    * after we unlock the mutex.
@@ -2440,7 +2341,6 @@ do_implicit_handshake (GTlsConnectionGnutls  *gnutls,
        * about. Run the actual operation as blocking in its thread. */
       *thread_timeout = -1;  /* blocking */
 
-GTLS_DEBUG(gnutls, "%s: started async_handshake_thread", __FUNCTION__);
       g_task_run_in_thread (priv->implicit_handshake,
                             async_handshake_thread);
 
@@ -2482,14 +2382,6 @@ g_tls_connection_gnutls_read (GTlsConnectionGnutls  *gnutls,
   ret = gnutls_record_recv (priv->session, buffer, count);
   END_GNUTLS_IO (gnutls, G_IO_IN, ret, _("Error reading data from TLS socket"), error);
 
-if (ret >= 0)
-{
-char *buf = g_malloc0 (ret + 1);
-memcpy (buf, buffer, ret);
-GTLS_DEBUG (gnutls, "%s: read %zd bytes: %s", __FUNCTION__, ret, buf);
-g_free (buf);
-}
-
   yield_op (gnutls, G_TLS_CONNECTION_GNUTLS_OP_READ);
 
   if (ret >= 0)
@@ -2497,11 +2389,8 @@ g_free (buf);
   else if (ret == GNUTLS_E_REHANDSHAKE)
     goto again;
   else
-{
-GTLS_DEBUG(gnutls, "%s: error %ld (%s) return -1", __FUNCTION__, ret, gnutls_strerror ((int)ret));
     return -1;
 }
-}
 
 static gsize
 input_vectors_from_gnutls_datum_t (GInputVector          *vectors,
@@ -2692,32 +2581,15 @@ g_tls_connection_gnutls_write (GTlsConnectionGnutls  *gnutls,
   ret = gnutls_record_send (priv->session, buffer, count);
   END_GNUTLS_IO (gnutls, G_IO_OUT, ret, _("Error writing data to TLS socket"), error);
 
-if (ret >= 0)
-{
-char *buf = g_malloc0 (ret + 1);
-memcpy (buf, buffer, ret);
-GTLS_DEBUG(gnutls, "%s: ret=%zd wrote %s", __FUNCTION__, ret, buf);
-g_free (buf);
-}
-
   yield_op (gnutls, G_TLS_CONNECTION_GNUTLS_OP_WRITE);
 
   if (ret >= 0)
-{
-GTLS_DEBUG(gnutls, "%s: write success!", __FUNCTION__);
     return ret;
-}
   else if (ret == GNUTLS_E_REHANDSHAKE)
-{
-GTLS_DEBUG(gnutls, "%s: AGAIN!", __FUNCTION__);
     goto again;
-}
   else
-{
-GTLS_DEBUG(gnutls, "%s error %ld (%s) return -1", __FUNCTION__, ret, gnutls_strerror ((int)ret));
     return -1;
 }
-}
 
 static gssize
 g_tls_connection_gnutls_write_message (GTlsConnectionGnutls  *gnutls,
diff --git a/tls/tests/connection.c b/tls/tests/connection.c
index b37f6c1..fbf359a 100644
--- a/tls/tests/connection.c
+++ b/tls/tests/connection.c
@@ -222,8 +222,6 @@ on_server_close_finish (GObject        *object,
   GError *expected_error = test->expected_server_error;
   GError *error = NULL;
 
-g_info("%s: server_error=%p", __FUNCTION__, test->server_error);
-
   g_io_stream_close_finish (G_IO_STREAM (object), res, &error);
   g_assert_no_error (error);
 
@@ -251,7 +249,6 @@ on_output_write_finish (GObject        *object,
 
   g_assert_no_error (test->server_error);
   g_output_stream_write_finish (G_OUTPUT_STREAM (object), res, &test->server_error);
-g_info("%s: server_error=%p", __FUNCTION__, test->server_error);
 
   if (!test->server_error && test->rehandshake)
     {


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