[glib-networking/mcatanzaro/tls-thread: 8/19] progress?



commit 5d1282dc1da5655af9825fa1649eb1207f4c1b07
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Fri Jul 26 15:07:14 2019 -0500

    progress?

 tls/base/gtlsconnection-base.c     |  1 +
 tls/base/gtlsthread.c              | 30 ++++++++++++++++++++++++------
 tls/gnutls/gtlsconnection-gnutls.c |  2 ++
 3 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 63008da..5b67185 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -1047,6 +1047,7 @@ static GSourceFuncs dtls_source_funcs =
   (GSourceDummyMarshal)g_cclosure_marshal_generic
 };
 
+/* FIXME: all needs to be threadsafe... */
 GSource *
 g_tls_connection_base_create_source (GTlsConnectionBase  *tls,
                                      GIOCondition         condition,
diff --git a/tls/base/gtlsthread.c b/tls/base/gtlsthread.c
index e92788f..1603780 100644
--- a/tls/base/gtlsthread.c
+++ b/tls/base/gtlsthread.c
@@ -179,14 +179,23 @@ static gpointer
 tls_thread (gpointer data)
 {
   GAsyncQueue *queue = data;
-  gboolean done = FALSE;
 
-  while (!done)
+  while (TRUE)
     {
       GTlsThreadOperation *op;
+      GIOCondition condition = 0;
 
+      /* FIXME: how do we simultaneously wait for a new queue item
+       * and also run the main loop? Add another GSource?
+       */
       op = g_async_queue_pop (queue);
 
+      if (op->type == G_TLS_THREAD_OP_SHUTDOWN)
+        {
+          g_tls_thread_operation_free (op);
+          break;
+        }
+
       switch (op->type)
         {
         case G_TLS_THREAD_OP_READ:
@@ -196,17 +205,26 @@ tls_thread (gpointer data)
                                                                                   &op->count,
                                                                                   op->cancellable,
                                                                                   &op->error);
+          condition = G_IO_IN;
           break;
         case G_TLS_THREAD_OP_SHUTDOWN:
           break;
         }
 
-      if (op->type != G_TLS_THREAD_OP_SHUTDOWN)
-        g_main_loop_quit (op->main_loop);
+      if (op->result != G_TLS_CONNECTION_BASE_WOULD_BLOCK)
+        {
+          g_main_loop_quit (op->main_loop);
+          g_tls_thread_operation_free (op);
+        }
       else
-        done = TRUE;
+        {
+          GSource *tls_source;
 
-      g_tls_thread_operation_free (op);
+          tls_source = g_tls_connection_base_create_source (op->connection,
+                                                            condition,
+                                                            op->cancellable);
+
+        }
     }
 
   g_async_queue_unref (queue);
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 9ce1d2c..ad1e949 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -514,6 +514,8 @@ set_gnutls_error (GTlsConnectionGnutls *gnutls,
     gnutls_transport_set_errno (priv->session, EIO);
 }
 
+/* FIXME: remove timeouts, make these always nonblocking */
+
 static ssize_t
 g_tls_connection_gnutls_pull_func (gnutls_transport_ptr_t  transport_data,
                                    void                   *buf,


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