[gnome-builder/wip/chergert/debugger: 27/46] mi2: delay next command until previous completes



commit 2c57206dd18609e80e75961917f79a840dbd5973
Author: Christian Hergert <chergert redhat com>
Date:   Fri Mar 24 02:57:34 2017 -0700

    mi2: delay next command until previous completes
    
    We not only need to wait for it to be sent on the wire, but for the
    reply to have come from gdb.

 contrib/mi2/mi2-client.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/contrib/mi2/mi2-client.c b/contrib/mi2/mi2-client.c
index adad16a..630a720 100644
--- a/contrib/mi2/mi2-client.c
+++ b/contrib/mi2/mi2-client.c
@@ -266,19 +266,18 @@ mi2_client_exec_write_message_cb (GObject      *object,
   g_autoptr(Mi2Client) self = user_data;
   g_autoptr(GError) error = NULL;
   Mi2ClientPrivate *priv = mi2_client_get_instance_private (self);
-  GCancellable *cancellable;
 
   g_assert (MI2_IS_OUTPUT_STREAM (stream));
   g_assert (G_IS_ASYNC_RESULT (result));
   g_assert (MI2_IS_CLIENT (self));
 
-
   if (!mi2_output_stream_write_message_finish (stream, result, &error))
     {
       g_autoptr(GTask) task = NULL;
 
       task = g_queue_pop_head (&priv->exec_tasks);
       g_task_return_error (task, g_steal_pointer (&error));
+      return;
     }
 
   /*
@@ -287,17 +286,6 @@ mi2_client_exec_write_message_cb (GObject      *object,
    * Successful completion of the task must come from a reply
    * sent to us by the peer looking something like ^running.
    */
-
-  /*
-   * Move forward to the next asynchronous command to execute.
-   */
-  cancellable = g_task_get_cancellable (priv->exec_tasks.head->data);
-  if (NULL != (message = g_queue_pop_head (&priv->exec_commands)))
-    mi2_output_stream_write_message_async (priv->output_stream,
-                                           message,
-                                           cancellable,
-                                           mi2_client_exec_write_message_cb,
-                                           g_steal_pointer (&self));
 }
 
 void
@@ -399,6 +387,7 @@ mi2_client_dispatch (Mi2Client  *self,
   else if (MI2_IS_REPLY_MESSAGE (message))
     {
       g_autoptr(GTask) task = g_queue_pop_head (&priv->exec_tasks);
+      g_autoptr(Mi2Message) next_message = NULL;
 
       if (task != NULL)
         {
@@ -409,6 +398,23 @@ mi2_client_dispatch (Mi2Client  *self,
           else
             g_task_return_pointer (task, g_object_ref (message), g_object_unref);
         }
+
+      /*
+       * Move forward to the next asynchronous command to execute.
+       * We do this here so that we don't have multiple requests on
+       * the wire at one time, as gdb cannot handle that.
+       */
+      if (NULL != (next_message = g_queue_pop_head (&priv->exec_commands)))
+        {
+          GCancellable *cancellable;
+
+          cancellable = g_task_get_cancellable (priv->exec_tasks.head->data);
+          mi2_output_stream_write_message_async (priv->output_stream,
+                                                 next_message,
+                                                 cancellable,
+                                                 mi2_client_exec_write_message_cb,
+                                                 g_steal_pointer (&self));
+        }
     }
   else
     {


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